chore: deploy initial linqpad queries

This commit is contained in:
Thom Lamb
2026-05-12 11:33:21 -05:00
parent 0a7a550d46
commit 96d0067f2d
120 changed files with 22939 additions and 0 deletions
@@ -0,0 +1,23 @@
<Query Kind="Statements">
<Connection>
<ID>db640701-a1c5-4177-9f03-5152d093ffa7</ID>
<Persist>true</Persist>
<Server>D0011-sql-01.sdt.local</Server>
<Database>jazz tst StrataSphere 20200612.1</Database>
<ShowServer>true</ShowServer>
</Connection>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
</Query>
var definitions = (from sdm in StandardDefinitionMappings select sdm).ToList();
//definitions
//.OrderBy(d => d.StandardDefinitionType)
//.ThenBy(d => $"{JObject.Parse(d.MappingMemberValue)["mappings"][0]["text"]}")
//.Select(x => new { x.StandardDefinitionGUID, x.StandardDefinitionType, x.MappingMemberValue }).Dump(nameof(definitions));
var inserts = definitions
.OrderBy(d => d.StandardDefinitionType)
.ThenBy(d => $"{JObject.Parse(d.MappingMemberValue)["mappings"][0]["text"]}")
.Aggregate("INSERT INTO dbo.StandardDefinitionMapping ( StandardDefinitionGUID, StandardDefinitionType, MappingMemberValue )\r\nVALUES",
(x, y) => $"{x}\r\n\t('{y.StandardDefinitionGUID}', N'{y.StandardDefinitionType}', N'{y.MappingMemberValue}'),");
inserts.TrimEnd(',').Dump(nameof(inserts));
@@ -0,0 +1,318 @@
<Query Kind="Program">
<Connection>
<ID>463c2997-8a6a-4688-9575-6549e5215f7b</ID>
<Persist>true</Persist>
<Server>D0011-SQL-01.sdt.local</Server>
<Database>jazz tst Riverside Health System 20190930.1</Database>
<ShowServer>true</ShowServer>
</Connection>
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<NuGetReference>RestSharp</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
<Namespace>RestSharp</Namespace>
</Query>
private string BaseUrl = "https://api-dev.sdt.local/StrataSphere.Web.API.Service/api/v1/";
private IList<StrataSphereMappedDefinition> _mappedDefinitions;
void Main()
{
RestClient client = new RestClient();
var definitions = GetList<DefinitionDto>(client, "Definitions");
var standardDefinitionMappings = from def in StandardDefinitionMappings
select new
{
def.MappingId,
def.StandardDefinitionGUID,
def.StandardDefinitionType,
MappingMemberValue = JsonConvert.DeserializeObject(def.MappingMemberValue)
};
var guidDefinitionDictionary = standardDefinitionMappings.ToDictionary(u => u.StandardDefinitionGUID);
var foundDefinitions = definitions.Where(p => guidDefinitionDictionary.ContainsKey(p.Id));
_mappedDefinitions = (from d in foundDefinitions
join m in StandardDefinitionMappings on d.Id equals m.StandardDefinitionGUID
select new StrataSphereMappedDefinition(d, m.MappingMemberValue)).ToList();
var pathAlias = "HIERALIAS";
var sqlTableAlias = "viewDimMetri";
var attributeID = new[] { "Cardiomyopathy" }.ToList();
StrataSphereMappedValue find;
attributeID.ForEach(id =>
{
find = MapToStrataSphere("[Case Type Family MSDRG]", "[Case Type Family MSDRG].[Case Type Family]",
new List<string> { $"{id}" });
find.Dump($"StrataSphereMappedValue: {id}");
});
}
// Define other methods and classes here
public StrataSphereMappedValue MapToStrataSphere(string dimensionId, string attributeId, IList<string> valuesToMap)
{
var mdx = new Regex(@"^(\[.+\]\.)+\[.+\]$");
var clientValues = valuesToMap.Select(valueToMap => mdx.IsMatch(valueToMap)
? AnalysisServicesUtils.GetMeasureIDFromMDXName(valueToMap)
: valueToMap).ToList();
return FindMappedValue(dimensionId, attributeId, clientValues);
}
public static class AnalysisServicesUtils
{
public static string GetMeasureIDFromMDXName(string aMemberMDXName)
{
return aMemberMDXName;
}
}
protected StrataSphereMappedValue FindMappedValue(string dimensionId, string attributeId, List<string> valuesToMap)
{
var definitions = _mappedDefinitions
.Where(d => d.DimensionId.Equals(dimensionId, StringComparison.CurrentCultureIgnoreCase)
&& d.AttributeId.Equals(attributeId, StringComparison.CurrentCultureIgnoreCase)).ToList();
var mappings = definitions.Where(p => p.MappedValues != null && p.MappedValues.mappings.Any()).SelectMany(p => p.MappedValues.mappings);
mappings.Dump();
var mappedDefinition = definitions
.SingleOrDefault(p => p.MappedValues != null
&& (!p.MappedValues.mappings.Any() ||
p.MappedValues.mappings.SelectMany(m => m.attributeValues
.Select(a => a.ToString()))
.OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ??
definitions
.SingleOrDefault(p => p.MappedValues != null
&& (!p.MappedValues.mappings.Any() ||
p.MappedValues.mappings
.Select(m => m.name)
.OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ??
definitions
.SingleOrDefault(p => p.MappedValues != null
&& (!p.MappedValues.mappings.Any() ||
p.MappedValues.mappings
.Select(m => m.text)
.OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ??
definitions
.SingleOrDefault(p => p.MappedValues != null
&& (!p.MappedValues.mappings.Any() ||
p.MappedValues.mappings
.Select(m => m.id)
.OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ??
definitions
.SingleOrDefault(p => p.MappedValues != null
&& (!p.MappedValues.mappings.Any() ||
p.MappedValues.mappings
.SelectMany(m => m.hierarchyPaths)
.OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ??
definitions.FirstOrDefault();
return mappedDefinition != null
? new StrataSphereMappedValue(valuesToMap, mappedDefinition.StrataSphereDefinitionGuid)
: new StrataSphereMappedValue(valuesToMap);
}
public struct StrataSphereMappedValue
{
public IList<string> ClientValues { get; set; }
public Guid? StrataSphereDefinitionGuid { get; set; }
public StrataSphereMappedValue(IList<string> clientValues)
{
ClientValues = clientValues;
StrataSphereDefinitionGuid = null;
}
public StrataSphereMappedValue(IList<string> clientValues, Guid definitionGuid)
{
ClientValues = clientValues;
StrataSphereDefinitionGuid = definitionGuid;
}
public bool IsMapped => StrataSphereDefinitionGuid.HasValue;
}
public class StrataSphereMappedDefinition
{
public StrataSphereMappedDefinition(DefinitionDto definitionDto, string mappedValues)
{
StrataSphereDefinitionGuid = definitionDto.Id;
HierarchyGuid = definitionDto.HierarchyGuid;
DimensionGuid = definitionDto.DimensionGuid;
AttributeGuid = definitionDto.AttributeGuid;
HierarchyId = definitionDto.HierarchyId;
DimensionId = definitionDto.DimensionId;
AttributeId = definitionDto.AttributeId;
MappedValues = JsonConvert.DeserializeObject<StrataSphereMappingValues>(mappedValues);
}
public Guid StrataSphereDefinitionGuid { get; }
public Guid HierarchyGuid { get; }
public Guid DimensionGuid { get; }
public Guid AttributeGuid { get; }
public string HierarchyId { get; }
public string DimensionId { get; }
public string AttributeId { get; }
public StrataSphereMappingValues MappedValues { get; }
}
public class StrataSphereMappingValues
{
public string HierarchyGUID { get; set; }
public string DimensionGUID { get; set; }
public List<string> values { get; set; }
public List<MappingValue> mappings { get; set; }
public List<string> hierarchyPaths { get; set; }
public StrataSphereMappingValues()
{
mappings = new List<MappingValue>();
}
}
public class MappingValue
{
public string id { get; set; }
public string displayHierarchyName { get; set; }
public string text { get; set; }
public string name { get; set; }
public List<object> attributeValues { get; set; }
public List<string> hierarchyPaths { get; set; }
public MappingValue()
{
attributeValues = new List<object>();
hierarchyPaths = new List<string>();
}
}
public class ApiBaseDto
{
/// <summary>
/// API Item Id Guid in StrataSphere
/// </summary>
/// <example>00000000-0000-0000-0000-000000000000</example>
public Guid Id { get; set; }
/// <summary>
/// When the API item was uploaded to StrataSphere
/// </summary>
public DateTime DateCreated { get; set; }
/// <summary>
/// When the API item was last updated in StrataSphere
/// </summary>
public DateTime DateLastModified { get; set; }
}
public class DefinitionDto : ApiBaseDto
{
/// <summary>
/// The name of the definition
/// </summary>
/// <example>TOP 10 DRGs BY SERVICE LINE</example>
public string Name { get; set; }
/// <summary>
/// A short description of the definition's content
/// </summary>
/// <example>Top 10 DRGs by Service Line filtered per service line rollup</example>
public string Description { get; set; } = "";
/// <summary>
/// The Guid of the Definition's hierarchy in a GM database
/// </summary>
/// <example>00000000-0000-0000-0000-000000000000</example>
public Guid HierarchyGuid { get; set; }
/// <summary>
/// The Guid of the Definition's dimension in a GM database
/// </summary>
/// <example>00000000-0000-0000-0000-000000000000</example>
public Guid DimensionGuid { get; set; }
/// <summary>
/// The Guid of the Definition's attribute in a GM database
/// </summary>
/// <example>00000000-0000-0000-0000-000000000000</example>
public Guid AttributeGuid { get; set; }
/// <summary>
/// The string of the Definition's hierarchy friendly name
/// </summary>
/// <example>PatientTypeRollupID</example>
public string HierarchyId { get; set; }
/// <summary>
/// The string of the Definition's dimension Id
/// </summary>
/// <example>[Patient Encounter]</example>
public string DimensionId { get; set; }
/// <summary>
/// The string of the Definition's attribute Id
/// </summary>
/// <example>[Patient Encounter].[Service Line Strata Decision]</example>
public string AttributeId { get; set; }
}
IEnumerable<T> GetList<T>(RestClient client, string something)
{
return Get<List<T>>(client, something);
}
T Get<T>(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
return JsonConvert.DeserializeObject<T>(client.Execute(request).Content);
}
@@ -0,0 +1,134 @@
<Query Kind="Program">
<Connection>
<ID>463c2997-8a6a-4688-9575-6549e5215f7b</ID>
<Persist>true</Persist>
<Server>D0011-SQL-01.sdt.local</Server>
<Database>StrataSphere</Database>
<ShowServer>true</ShowServer>
</Connection>
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<NuGetReference>RestSharp</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
<Namespace>RestSharp</Namespace>
<Namespace>System.Dynamic</Namespace>
</Query>
private string BaseUrl = "https://api-prod.sdt.local/starterset-api/api/v1/"; //"https://starterset-api.dev.k8s.sdt.local/api/v1/";
void Main()
{
RestClient client = new RestClient();
client.BaseUrl = new Uri(BaseUrl.Replace("/api/v1/", "/health"));
RestRequest request = new RestRequest();
request.Method = Method.GET;
client.Execute(request).Content.Dump("health");
var definitions = GetList<DefinitionDto>(client, "Definitions");
definitions?
.OrderBy(d => d.Name).ThenBy(d => d.AttributeId)
.Dump(nameof(definitions));
var mdx = GetList<MDXScoreToCube>(client, "MdxScoreToCube");
mdx?
.OrderBy(d => d.ScoreDimensionName).ThenBy(d => d.CubeDimensionName)
.Dump(nameof(mdx));
}
// Define other methods and classes here
dynamic GetList(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
var converter = new ExpandoObjectConverter();
return JsonConvert.DeserializeObject<ExpandoObject>(client.Execute(request).Content, converter);
}
IEnumerable<T> GetList<T>(RestClient client, string something)
{
return Get<List<T>>(client, something);
}
T Get<T>(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
return JsonConvert.DeserializeObject<T>(client.Execute(request).Content,
new JsonSerializerSettings
{
Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
{
args.ErrorContext.Error.Message.Dump();
args.ErrorContext.Handled = true;
}
});
}
public class DefinitionDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Guid HierarchyGuid { get; set; }
public Guid DimensionGuid { get; set; }
public Guid AttributeGuid { get; set; }
public string HierarchyId { get; set; }
public string DimensionId { get; set; }
public string AttributeId { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
public DefinitionDto()
{
}
}
@@ -0,0 +1,138 @@
<Query Kind="Program">
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<NuGetReference>RestSharp</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
<Namespace>RestSharp</Namespace>
<Namespace>System.Dynamic</Namespace>
</Query>
private string BaseUrl = "https://starterset-api.dev.k8s.sdt.local/api/v1/";
void Main()
{
RestClient client = new RestClient();
var mdxScoreToCubes = GetList<MdxScoreToCubeDto>(client, "MdxScoreToCube");
mdxScoreToCubes
.Where(stc => stc.ScoreDimensionName == "MR Metrics")
//.Where(d => d.DimensionGuid.ToString().Equals("A1823417-0B73-9950-D44C-2F3A9B9DDB92", StringComparison.CurrentCultureIgnoreCase))
//.OrderBy(d => d.DimensionId)
.Dump(nameof(mdxScoreToCubes));
}
// Define other methods and classes here
dynamic GetList(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
var converter = new ExpandoObjectConverter();
return JsonConvert.DeserializeObject<ExpandoObject>(client.Execute(request).Content, converter);
}
IEnumerable<T> GetList<T>(RestClient client, string something)
{
return Get<List<T>>(client, something);
}
T Get<T>(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
return JsonConvert.DeserializeObject<T>(client.Execute(request).Content,
new JsonSerializerSettings
{
Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
{
args.ErrorContext.Error.Message.Dump();
args.ErrorContext.Handled = true;
}
});
}
public class MdxScoreToCubeDto
{
public Guid Id { get; set; }
public string OrgPin { get; set; }
public Guid DatabaseGuid { get; set; }
public string ScoreDimensionName { get; set; }
public string ScoreHierarchyName { get; set; }
public string CubeDimensionName { get; set; }
public string CubeHierarchyName { get; set; }
public MdxMemberIdTypes MdxMemberIdType {get;set;}
public MdxForamtTypes MdxFormatType {get;set;}
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
public MdxScoreToCubeDto()
{
}
}
public enum MdxMemberIdTypes
{
Attribute,
Name,
Text,
Id,
HierarchyPath
}
public enum MdxForamtTypes
{
None,
MDX,
Hierarchy,
MDXMemberId,
Raw
}
+872
View File
@@ -0,0 +1,872 @@
<Query Kind="Program">
<Connection>
<ID>db640701-a1c5-4177-9f03-5152d093ffa7</ID>
<Persist>true</Persist>
<Server>D0011-sql-01.sdt.local</Server>
<Database>jazz tst StrataSphere 20191104.1</Database>
<ShowServer>true</ShowServer>
</Connection>
<NuGetReference>Newtonsoft.Json</NuGetReference>
<NuGetReference>RestSharp</NuGetReference>
<Namespace>RestSharp</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>System.Dynamic</Namespace>
</Query>
private string BaseUrl = @"https://localhost:44325/api/v1/";
void Main()
{
RestClient client = new RestClient();
var reports = GetList<ReportDto>(client, "Reports");
reports.Dump();
}
dynamic GetList(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
var converter = new ExpandoObjectConverter();
return JsonConvert.DeserializeObject<ExpandoObject>(client.Execute(request).Content, converter);
}
void other()
{
StandardDefinitionMappings.Select(sdm => new
{
sdm.MappingId,
sdm.StandardDefinitionGUID,
sdm.StandardDefinitionType,
MappingMemberValue = JsonConvert.DeserializeObject<StrataSphereMappingValues>(sdm.MappingMemberValue)
}).Dump("StandardDefinitionMappings");
REReports.Join(REDSCubeReportParameters,
r => r.ReportGUID,
p => p.ReportGUID,
(r, p) => new ReportInfo(p.ParameterXML)
{
Report = r.Name,
DimensionID = p.DimensionID,
AttributeID = p.AttributeID
}).Dump("Cube Reports");
REReports.Join(REClientReportParameters,
r => r.ReportGUID,
p => p.ReportGUID,
(r, p) => new ReportInfo(p.ParameterXML)
{
Report = r.Name,
DimensionID = p.DimensionID,
AttributeID = p.AttributeID
}).Dump("Client Reports");
}
IEnumerable<T> GetList<T>(RestClient client, string something)
{
return Get<List<T>>(client, something);
}
T Get<T>(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
return JsonConvert.DeserializeObject<T>(client.Execute(request).Content,
new JsonSerializerSettings
{
Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
{
args.ErrorContext.Error.Message.Dump();
args.ErrorContext.Handled = true;
}
});
}
void stuff(RestClient client)
{
client.BaseUrl = new Uri(BaseUrl + "Definitions");
RestRequest request = new RestRequest();
request.Method = Method.GET;
var definitions = JsonConvert.DeserializeObject<List<DefinitionDto>>(client.Execute(request).Content);
definitions.Where(d => d.DimensionGuid == new Guid("6EF6B1F7-A50C-4198-8866-140BB82E2DDA")).Dump("Definitions");
client.BaseUrl = new Uri(BaseUrl + "MDXScoreToCube");
var mdx = JsonConvert.DeserializeObject<List<MDXScoreToCubeDto>>(client.Execute(request).Content);
mdx.Dump("MDX");
client.BaseUrl = new Uri(BaseUrl + "Reports");
var reports = JsonConvert.DeserializeObject<List<ReportDto>>(client.Execute(request).Content);
reports.Dump("Reports");
var reportSetupUrl = new Uri(BaseUrl + "Reports/{0}/Setup");
reports.Where(r => r.Id == new Guid("a4a12e21-954b-4889-d5c8-08d71f2ff590")).ToList().ForEach(r =>
{
client.BaseUrl = new Uri(BaseUrl + $"Reports/{r.Id}");
var rpt = JsonConvert.DeserializeObject<ReportDto>(client.Execute(request).Content);
rpt.DefinitionIds.ForEach(d =>
{
client.BaseUrl = new Uri(BaseUrl + $"Defintions/{d}");
var definition = JsonConvert.DeserializeObject<List<DefinitionDto>>(client.Execute(request).Content);
definition.Dump($"Report {r.Name} Definition {d}");
});
});
}
// Define other methods and classes here
public class ReportInfo
{
public string Report { get; set; }
public string DimensionID { get; set; }
public string AttributeID { get; set; }
public string ParameterXML { get; set; }
internal XmlDocument doc;
public string Parameter { get; set; }
public ReportInfo(string parameterXML)
{
ParameterXML = parameterXML;
var parameterXml = ParameterXML = $"<root>{ParameterXML}</root>"
.RemoveAllNamespacesAsString()
.Replace("string>", "valueId>")
.Replace("<Value2 i:nil=\"true\" />", "<Value2 />")
.Replace("<_", "<").Replace("</_", "</")
.Replace("p5:nil=\"true\" xmlns:p5=\"http://www.w3.org/2001/XMLSchema-instance\"", "");
XmlDocument doc = new XmlDocument();
doc.LoadXml(parameterXml);
Parameter = JsonConvert.SerializeObject(
JsonConvert.DeserializeObject<dynamic>(
JsonConvert.SerializeXmlNode(doc.SelectSingleNode("root")
)
)
,
Newtonsoft.Json.Formatting.Indented);
}
}
public class StrataSphereMappingValues
{
public string HierarchyGUID { get; set; }
public string DimensionGUID { get; set; }
public List<string> values { get; set; }
public List<MappingValue> mappings { get; set; }
public List<string> hierarchyPaths { get; set; }
public StrataSphereMappingValues()
{
mappings = new List<MappingValue>();
}
}
public class MappingValue
{
public string id { get; set; }
public string displayHierarchyName { get; set; }
public string text { get; set; }
public string name { get; set; }
public List<object> attributeValues { get; set; }
public List<string> hierarchyPaths { get; set; }
public MappingValue()
{
attributeValues = new List<object>();
hierarchyPaths = new List<string>();
}
}
public enum eStrataSphereItemCategory
{
Report,
Dashboard
}
public enum StrataSphereReportEnum
{
Report,
DSCubeReport,
SQLReport,
ClientReport
}
public class ReportDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Author { get; set; }
public eStrataSphereItemCategory Category => eStrataSphereItemCategory.Report;
public string Tagline =>
$"Report | {Module} | {DateCreated.ToString("MMM-dd-YYYY")} | {DownloadCount} downloads";
public StrataSphereReportEnum ReportType { get; set; }
public string Module { get; set; }
public string MinJazzVersion { get; set; }
public string MaxJazzVersion { get; set; }
public string ReportSetupJson { get; set; }
public List<Guid> DefinitionIds { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
public int DownloadCount { get; set; }
public ReportDto()
{
ReportSetupJson = "{}";
DefinitionIds = new List<Guid>();
}
}
public class DefinitionDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Guid HierarchyGuid { get; set; }
public Guid DimensionGuid { get; set; }
public Guid AttributeGuid { get; set; }
public string HierarchyId { get; set; }
public string DimensionId { get; set; }
public string AttributeId { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
}
public enum MDXMemberIDTypeEnum
{
Attribute,
Name,
Text,
Id,
HierarchyPath
}
public enum MDXFormatTypeEnum
{
None,
MDX,
Hierarchy,
MDXMemberId
}
public class MDXScoreToCubeDto
{
public string OrgPin { get; set; }
public Guid DatabaseGuid { get; set; }
public string ScoreDimensionName { get; set; }
public string ScoreHierarchyName { get; set; }
public string CubeDimensionName { get; set; }
public string CubeHierarchyName { get; set; }
public MDXMemberIDTypeEnum MDXMemberIDType { get; set; }
public MDXFormatTypeEnum MDXFormatType { get; set; }
}
public class ValueIDArray
{
public List<string> valueId { get; set; }
}
public class DSCubeSearchCondition
{
public string FilterOp { get; set; }
public string SearchType { get; set; }
public string Value2 { get; set; }
public string Value { get; set; }
public ValueIDArray ValueIDArray { get; set; }
}
public class SearchConditions
{
public DSCubeSearchCondition DSCubeSearchCondition { get; set; }
}
public class DSCubeSearchParameterValue
{
public string ParameterGUID { get; set; }
public string ParameterValueGUID { get; set; }
public SearchConditions SearchConditions { get; set; }
}
public class Root
{
public DSCubeSearchParameterValue DSCubeSearchParameterValue { get; set; }
}
public class RootObject
{
public Root root { get; set; }
}
#region StrataSphereAdHocReportSetup
public interface IStrataSphereAdHocReportSectionItem
{
string Name { get; set; }
bool IsOnChartXAxis { get; set; }
bool IsOnChartYAxis { get; set; }
}
internal class StrataSphereAdHocReportAttribute : IStrataSphereAdHocReportSectionItem
{
public StrataSphereAdHocReportAttribute()
{
}
public string AttributeId { get; set; }
public string DimensionId { get; set; }
public int Index { get; set; }
public string Name { get; set; }
public IList<string> FilterMembers { get; set; }
public int VisibilityStatusValue { get; set; }
public bool ShowSubtotal { get; set; }
public bool IsOnChartXAxis { get; set; }
public bool IsOnChartYAxis { get; set; }
// section level filters
public List<object> Parameters { get; set; } = new List<object>();
//public List<StrataSphereAdHocReportParameter> Parameters { get; set; } = new List<StrataSphereAdHocReportParameter>();
}
internal class StrataSphereAdHocReportCalculation : IStrataSphereAdHocReportSectionItem
{
public StrataSphereAdHocReportCalculation()
{
}
public string Name { get; set; }
public string CalcType { get; set; }
public int DisplayOrder { get; set; }
public string DisplayFormat { get; set; }
public int ColumnWidth { get; set; }
public string CalculationJson { get; set; }
public string CssClass { get; set; }
public bool IsAttributeMember { get; set; }
public bool IsOnChartXAxis { get; set; }
public bool IsOnChartYAxis { get; set; }
public List<StrataSphereAdHocReportConditionalFormat> ConditionalFormats { get; set; } = new List<StrataSphereAdHocReportConditionalFormat>();
}
internal class StrataSphereAdHocReportConditionalFormat
{
public StrataSphereAdHocReportConditionalFormat()
{
}
public string Comment { get; set; }
public int DisplayOrder { get; set; }
public ReportTupleInfo ColumnTupleInfo { get; set; }
public string CssClass { get; set; }
public string ValueToCompareAsString { get; set; }
public int OperatorValue { get; set; }
}
internal class StrataSphereAdHocReportConfig
{
public string Title { get; set; }
public string Description { get; set; }
public string[] Colors { get; set; }
public AxisSetting AxisSettings { get; set; }
public string XType { get; set; }
public bool YAxisMultiSelect { get; set; }
public Guid XAxisSectionItemGuid { get; set; }
public List<Guid> YAxisSectionItemGuids { get; set; } = new List<Guid>();
public StrataSphereAdHocReportConfig(BaseConfig source)
{
if (source == null) return;
Title = source.Title;
Description = source.Description;
Colors = source.Colors;
AxisSettings = source.AxisSettings;
XType = source.XType;
YAxisMultiSelect = source.YAxisMultiSelect;
}
public BaseConfig GetChartConfig()
{
var chartConfig = default(BaseConfig);
/*
// Try decoding the xType by the name first
var asm = typeof(AreaConfig).Assembly;
var type = asm.GetType($"{asm.GetName().Name}.Reporting.ChartConfigs.{XType}");
if (type != null)
{
chartConfig = (BaseConfig)Activator.CreateInstance(type);
}
else // if that failed then use the hard coded selector, this is an issue if new types are supported
{
switch (XType)
{
case "AreaConfig":
chartConfig = new AreaConfig();
break;
case "BarConfig":
chartConfig = new BarConfig();
break;
case "BubbleConfig":
chartConfig = new BubbleConfig();
break;
case "ColumnConfig":
chartConfig = new ColumnConfig();
break;
case "ComboColumnAndLineConfig":
chartConfig = new ComboColumnAndLineConfig();
break;
case "ComboColumnAndLineWithSecondaryAxisConfig":
chartConfig = new ComboColumnAndLineWithSecondaryAxisConfig();
break;
case "DonutConfig":
chartConfig = new DonutConfig();
break;
case "LineConfig":
chartConfig = new LineConfig();
break;
case "PieConfig":
chartConfig = new PieConfig();
break;
case "ScatterConfig":
chartConfig = new ScatterConfig();
break;
case "SplineConfig":
chartConfig = new SplineConfig();
break;
case "StackedBarConfig":
chartConfig = new StackedBarConfig();
break;
case "StackedBarPercentConfig":
chartConfig = new StackedBarPercentConfig();
break;
case "StackedColumnConfig":
chartConfig = new StackedColumnConfig();
break;
case "StackedColumnPercentConfig":
chartConfig = new StackedColumnPercentConfig();
break;
}
}
*/
if (chartConfig == null) return chartConfig;
chartConfig.Title = Title;
chartConfig.Description = Description;
chartConfig.Colors = Colors;
chartConfig.AxisSettings = AxisSettings;
// if (chartConfig is XYConfig xyConfig)
// {
// xyConfig.XAxisSectionItemGuid = XAxisSectionItemGuid;
// xyConfig.YAxisSectionItemGuids.AddRange(YAxisSectionItemGuids);
// }
return chartConfig;
}
}
internal class StrataSphereAdHocReportDataSource
{
public StrataSphereAdHocReportDataSource()
{
}
public Guid DataSourceGuid { get; set; }
public string Name { get; set; }
public int DataSourceType { get; set; }
}
internal class StrataSphereAdHocReportMeasure : IStrataSphereAdHocReportSectionItem
{
public StrataSphereAdHocReportMeasure()
{
}
public string MeasureId { get; set; }
public string Name { get; set; }
public int Index { get; set; }
public string DisplayFormat { get; set; }
public int ColumnWidth { get; set; }
public bool IsOnChartXAxis { get; set; }
public bool IsOnChartYAxis { get; set; }
// section level filters
public List<StrataSphereAdHocReportParameter> Parameters { get; set; } = new List<StrataSphereAdHocReportParameter>();
public List<StrataSphereAdHocReportConditionalFormat> ConditionalFormats { get; set; } = new List<StrataSphereAdHocReportConditionalFormat>();
}
internal class StrataSphereAdHocReportSection
{
public StrataSphereAdHocReportSection()
{
}
public string Name { get; set; }
public bool IsOnColumn { get; set; }
public int DisplayOrder { get; set; }
public bool IsTimeRelative { get; set; }
public bool IsFinancialReportSectionHidable { get; set; }
public bool IsMergingRepeatHeader { get; set; }
public bool IsSpaceAbove { get; set; }
public bool IsHidden { get; set; }
public string DisplayLabel { get; set; }
public bool ShowSectionLabel { get; set; }
public bool ShowGrandTotal { get; set; }
public bool IsAutoNameFilter { get; set; }
public bool ShowMargin { get; set; }
public List<object> Attributes { get; set; } = new List<object>();
public List<object> Measures { get; set; } = new List<object>();
public List<object> Calculations { get; set; } = new List<object>();
}
internal class StrataSphereAdHocReportSetup
{
public string Style { get; set; }
public StrataSphereAdHocReportSortArgs SortArgs { get; set; }
public List<StrataSphereAdHocReportDataSource> DataSources { get; set; } = new List<StrataSphereAdHocReportDataSource>();
public StrataSphereAdHocReportConfig ChartConfig { get; set; } = null;
public List<StrataSphereAdHocReportSection> Sections { get; set; } = new List<StrataSphereAdHocReportSection>();
public List<StrataSphereAdHocReportParameter> Parameters { get; set; } = new List<StrataSphereAdHocReportParameter>();
public List<StrataSphereAdHocScoreDimensionInfo> ServiceLines { get; set; } =
new List<StrataSphereAdHocScoreDimensionInfo>();
}
public class StrataSphereAdHocReportSortArgs
{
public StrataSphereAdHocReportTupleInfo TupleInfo { get; set; }
public bool IsAscending { get; set; }
public int SortCount { get; set; }
public int Top { get; set; }
public bool IsTopPercent { get; set; }
public bool IsIncludeAllOthers { get; set; }
public StrataSphereAdHocReportSortArgs()
{
TupleInfo = new StrataSphereAdHocReportTupleInfo();
}
}
public class StrataSphereAdHocReportTupleInfo
{
public Dictionary<string, string> PartialRowTuple { get; set; }
public Dictionary<string, string> PartialColTuple { get; set; }
public string MainMeasureName { get; private set; }
public string RowMeasureName { get; set; }
public string ColMeasureName { get; set; }
public Guid ColMeasureGUID { get; set; }
public string FormatString { get; set; }
public int rowIndex { get; set; }
public int colIndex { get; set; }
public Guid ColumnSectionGUID { get; set; }
public IAdHocReportSectionMeasure MainMeasure { get; set; }
public StrataSphereAdHocReportTupleInfo()
{
PartialRowTuple = new Dictionary<string, string>();
PartialColTuple = new Dictionary<string, string>();
ColumnSectionGUID = Guid.Empty;
ColMeasureGUID = Guid.Empty;
}
public StrataSphereAdHocReportTupleInfo(ReportTupleInfo tupleInfo)
: this()
{
if (tupleInfo == null) return;
tupleInfo.PartialRowTuple.Keys.ToList()
.ForEach(key => PartialRowTuple.Add(key, tupleInfo.PartialRowTuple[key]));
tupleInfo.PartialColTuple.Keys.ToList()
.ForEach(key => PartialColTuple.Add(key, tupleInfo.PartialColTuple[key]));
//MainMeasure = tupleInfo.MainMeasure;
MainMeasureName = tupleInfo.MainMeasureName;
RowMeasureName = tupleInfo.RowMeasureName;
ColMeasureName = tupleInfo.ColMeasureName;
ColMeasureGUID = tupleInfo.ColMeasureGUID;
FormatString = tupleInfo.FormatString;
rowIndex = tupleInfo.rowIndex;
colIndex = tupleInfo.colIndex;
ColumnSectionGUID = tupleInfo.ColumnSectionGUID;
}
public static implicit operator ReportTupleInfo(StrataSphereAdHocReportTupleInfo tupleInfo)
{
if (tupleInfo == null) return null;
var result = new ReportTupleInfo
{
PartialRowTuple = new Dictionary<string, string>(),
PartialColTuple = new Dictionary<string, string>(),
MainMeasure = tupleInfo.MainMeasure?.CopyMeasure(),
RowMeasureName = tupleInfo.RowMeasureName,
ColMeasureName = tupleInfo.ColMeasureName,
ColMeasureGUID = tupleInfo.ColMeasureGUID,
FormatString = tupleInfo.FormatString,
rowIndex = tupleInfo.rowIndex,
colIndex = tupleInfo.colIndex,
ColumnSectionGUID = tupleInfo.ColumnSectionGUID
};
tupleInfo.PartialRowTuple.Keys.ToList()
.ForEach(key => result.PartialRowTuple.Add(key, tupleInfo.PartialRowTuple[key]));
tupleInfo.PartialColTuple.Keys.ToList()
.ForEach(key => result.PartialColTuple.Add(key, tupleInfo.PartialColTuple[key]));
return result;
}
}
internal interface IStrataReportParameter
{
string DimensionId { get; set; }
string AttributeId { get; set; }
}
internal abstract class StrataSphereAdHocReportParameter : IStrataReportParameter
{
protected StrataSphereAdHocReportParameter()
{
}
public string Name { get; set; }
public string DimensionId { get; set; }
public string AttributeId { get; set; }
public string MeasureId { get; set; }
public int DisplayOrder { get; set; }
public bool IsUserEditable { get; set; }
public bool IsAttributeParameter => string.IsNullOrWhiteSpace(MeasureId);
}
public class StrataSphereAdHocScoreDimensionInfo
{
public Guid DimensionGUID { get; set; }
public string FriendlyName { get; set; }
public string GlobalID { get; set; }
public string AttributeId { get; set; }
public string MDXMemberID { get; set; }
public bool IsRollup { get; set; }
internal Regex ServiceLineRegex = new Regex(@"^Service Line (\d)$", RegexOptions.IgnoreCase);
// internal string MDXMemberName => AnalysisServicesUtils.GetHierarchyMDXName("Patient Encounter",
// ServiceLineRegex.IsMatch(FriendlyName) && IsRollup
// ? $"{ServiceLineRegex.Replace(FriendlyName, "Service Line Rollup ${1}")}"
// : $"{FriendlyName}{(IsRollup ? " Rollup" : "")}");
internal string Name => $"Patient Encounter - {FriendlyName}{(IsRollup ? " Rollup" : "")}";
internal StrataSphereAdHocScoreDimensionInfo()
{
MDXMemberID = string.Empty;
IsRollup = false;
}
}
#endregion
#region Other Stuff
public interface IAdHocReportSectionMeasure //: IAdHocReportSectionItem
{
string ColumnName { get; set; }
string DisplayFormat { get; }
string CSSClass { get; }
List<Guid> LinkedSectionGUIDs { get; }
void Hide();
string MeasureID { get; }
bool IsPartial { get; }
bool IsAttributeMember { get; }
eAggregateFunction AggregationTypeEnum { get; }
IAdHocReportSectionMeasure CopyMeasure();
}
public interface ITGuid<T>
{
Guid Value { get; set; }
bool IsEmpty { get; set; }
}
public enum eClientReportSectionItemType
{
Attribute = 0,
Hierarchy = 1,
Measure = 2,
Calculation = 3
}
public enum eReportDrilldownStatus
{
None = 0,
Drilldown = 1,
Drillup = 2
}
public enum eClientReportVisibilityStatus
{
Hidden = 0,
CompletelyVisible = 1,
PartiallyVisible = 2
}
public enum eAggregateFunction
{
Sum = 0,
Count = 1,
Avg = 2,
Min = 3,
Max = 4,
None = 5
}
public interface IAdHocReportSectionAttribute //: IAdHocReportSectionItem
{
ITGuid<IAdHocReportSectionAttribute> AttributeGUIDTyped { get; }
string DimensionID { get; }
string AttributeID { get; }
bool ShowSubtotal { get; set; }
SortOrder SortOrder { get; }
eClientReportVisibilityStatus VisibilityStatus { get; set; }
eReportDrilldownStatus DrilldownStatus { get; set; }
string FilterMemberCSV { get; set; }
List<string> FilterMembers { get; set; }
List<string> FilterMembersVisible { get; }
}
public class ReportTupleInfo
{
public ReportTupleInfo()
{
this.PartialRowTuple = new Dictionary<string, string>();
this.PartialColTuple = new Dictionary<string, string>();
}
private Dictionary<string, string> _Tuple;
public Dictionary<string, string> Tuple
{
get
{
return _Tuple;
}
set { _Tuple = value; }
}
public Dictionary<string, string> PartialRowTuple { get; set; }
public Dictionary<string, string> PartialColTuple { get; set; }
public string MainMeasureName { get; private set; }
private IAdHocReportSectionMeasure _MainMeasure;
public IAdHocReportSectionMeasure MainMeasure
{
get { return _MainMeasure; }
set
{
_MainMeasure = value;
MainMeasureName = (value == null) ? string.Empty : value.ColumnName;
}
}
public string RowMeasureName { get; set; }
public string ColMeasureName { get; set; }
public Guid ColMeasureGUID { get; set; }
public string FormatString { get; set; }
public int rowIndex { get; set; }
public int colIndex { get; set; }
public Guid ColumnSectionGUID { get; set; }
}
public class AxisSetting
{
public string XAxisLabel { get; set; }
public string YAxisLabel { get; set; }
public double? YAxisLowerBound { get; set; }
public double? YAxisUpperBound { get; set; }
public double? YAxisTickInterval { get; set; }
public double? YAxisPlotLineValue { get; set; }
public bool ShowDataLabel { get; set; }
public override bool Equals(object obj)
{
var config = (AxisSetting)obj;
if (config == null) return false;
if (config.XAxisLabel != this.XAxisLabel) return false;
if (config.YAxisLabel != this.YAxisLabel) return false;
if (config.YAxisLowerBound != this.YAxisLowerBound) return false;
if (config.YAxisUpperBound != this.YAxisUpperBound) return false;
if (config.YAxisTickInterval != this.YAxisTickInterval) return false;
if (config.YAxisPlotLineValue != this.YAxisPlotLineValue) return false;
if (config.ShowDataLabel != this.ShowDataLabel) return false;
return true;
}
}
public abstract class BaseConfig
{
public abstract DataTable GetData(object report);
public abstract string Name { get; }
public string Title { get; set; }
public string Description { get; set; }
public string[] Colors { get; set; }
public AxisSetting AxisSettings { get; set; }
public virtual string IconName { get { return ""; } }
public virtual string XType { get { return ""; } }
public virtual string SectionName { get { return ""; } }
public virtual int ColumnNumber { get { return -1; } }
public virtual int RowNumber { get { return -1; } }
public virtual bool YAxisMultiSelect { get { return true; } }
protected BaseConfig()
{
this.Colors = new string[] { };
this.AxisSettings = new AxisSetting();
}
public override bool Equals(object obj)
{
var config = (BaseConfig)obj;
if (config == null) return false;
if (config.Title != Title || config.Description != Description) return false;
if (config.Colors.Length != Colors.Length) return false;
if (config.Colors.Any(p => !Colors.Contains(p))) return false;
if (!config.AxisSettings.Equals(this.AxisSettings)) return false;
if (config.GetType().Name != this.GetType().Name) return false;
return true;
}
}
#endregion
@@ -0,0 +1,96 @@
<Query Kind="Program">
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<NuGetReference>RestSharp</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
<Namespace>RestSharp</Namespace>
</Query>
private string BaseUrl = @"https://api-prod.sdt.local/starterset-api";
private string Resource = @"Reports/Populate";
void Main()
{
var client = new RestClient();
BaseUrl += "/api/v1";
client.BaseUrl = new Uri(BaseUrl);
DumpEndpoint(client, "prod");
Resource = @"Reports/Test";
DumpEndpoint(client, "Test");
Resource = @"Reports/a281733b-30d8-4d51-2148-08d799ffe4e4/Setup";
DumpEndpoint(client, Resource);
Resource = @"Reports/Populate";
var environments = new[] { "dev", "qa", "training" }.ToList();
environments.ForEach(env =>
{
DumpEnv(client, env);
});
}
void DumpEnv(RestClient client, string env)
{
BaseUrl = $@"https://starterset-api.{env}.k8s.sdt.local";
BaseUrl += "/api/v1";
client.BaseUrl = new Uri(BaseUrl);
DumpEndpoint(client, env);
}
void DumpEndpoint(RestClient client, string env)
{
var request = new RestRequest();
request.Method = Method.GET;
request.Resource = Resource;
var response = client.Execute(request);
response.Content.Dump(env);
}
// Define other methods and classes here
@@ -0,0 +1,908 @@
<Query Kind="Program">
<Output>DataGrids</Output>
<NuGetReference>Newtonsoft.Json</NuGetReference>
<NuGetReference>RestSharp</NuGetReference>
<Namespace>RestSharp</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>System.Dynamic</Namespace>
</Query>
private string BaseUrl =
//"https://starterset-api.dev.k8s.sdt.local/api/v1/";
"https://localhost:44325/api/v1/";
void Main()
{
RestClient client = new RestClient();
var reports = GetList<ReportDto>(client, "Reports");
var rpts = reports
.Where(r => r.Name.StartsWith("TL Fiscal Month Test"))
.OrderBy(r => r.Name)
.ToList()
.Select(rpt => new { rpt.Id, rpt.Name, setup = GetList(client, $"Reports\\{rpt.Id}\\Setup") })
//.Where(x => ((IDictionary<String, object>)x.setup).ContainsKey("ServiceLines"))
;
rpts.Dump(nameof(rpts),6);
var definitions = GetList<DefinitionDto>(client, "Definitions")
.Where(dd => dd.DimensionId == "e18e27ea-52ec-4793-9209-c6259c78474a"
|| dd.DimensionId == "Fiscan Month");
definitions.Dump();
/*
var setups = rpts.Select(r => r.setup);
setups.Dump(nameof(setups));
var serviceLines = setups.Where(x => ((IDictionary<String, object>)x).ContainsKey("ServiceLines"))
.SelectMany(s => ((List<Object>)s.ServiceLines)
.Select(x => x));
serviceLines.Dump(nameof(serviceLines));
var dataSources = setups.SelectMany(s => ((List<Object>)s.DataSources)
.Select(x => JsonConvert.DeserializeObject<StrataSphereAdHocReportDataSource>(JsonConvert.SerializeObject(x))))
.GroupBy(ds => ds.DataSourceGuid, (g, d) => d.First());
dataSources.Dump(nameof(dataSources));
// var globalParameters = setups.SelectMany(s => ((List<Object>)s.Parameters)
// .Select(x => JsonConvert.DeserializeObject<StrataSphereAdHocReportParameter>(JsonConvert.SerializeObject(x))));
// globalParameters.Dump(nameof(globalParameters));
var sections = setups.SelectMany(s => ((List<Object>)s.Sections)
.Select(x => JsonConvert.DeserializeObject<StrataSphereAdHocReportSection>(JsonConvert.SerializeObject(x))));
var attributes = sections.SelectMany(s => s.Attributes)
.Select(x => JsonConvert.DeserializeObject<StrataSphereAdHocReportAttribute>(JsonConvert.SerializeObject(x)));
attributes.Dump(nameof(attributes));
var attrParms = attributes.SelectMany(a => a.Parameters);
attrParms.Dump(nameof(attrParms));
var calculations = sections.SelectMany(s => s.Calculations)
.Select(x => JsonConvert.DeserializeObject<StrataSphereAdHocReportCalculation>(JsonConvert.SerializeObject(x)));
calculations.Dump(nameof(calculations));
*/
}
dynamic GetList(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
var converter = new ExpandoObjectConverter();
return JsonConvert.DeserializeObject<ExpandoObject>(client.Execute(request).Content, converter);
}
//void other()
//{
// StandardDefinitionMappings.Select(sdm => new
// {
// sdm.MappingId,
// sdm.StandardDefinitionGUID,
// sdm.StandardDefinitionType,
// MappingMemberValue = JsonConvert.DeserializeObject<StrataSphereMappingValues>(sdm.MappingMemberValue)
// }).Dump("StandardDefinitionMappings");
//
// REReports.Join(REDSCubeReportParameters,
// r => r.ReportGUID,
// p => p.ReportGUID,
// (r, p) => new ReportInfo(p.ParameterXML)
// {
// Report = r.Name,
// DimensionID = p.DimensionID,
// AttributeID = p.AttributeID
// }).Dump("Cube Reports");
//
// REReports.Join(REClientReportParameters,
// r => r.ReportGUID,
// p => p.ReportGUID,
// (r, p) => new ReportInfo(p.ParameterXML)
// {
// Report = r.Name,
// DimensionID = p.DimensionID,
// AttributeID = p.AttributeID
// }).Dump("Client Reports");
//}
IEnumerable<T> GetList<T>(RestClient client, string something)
{
return Get<List<T>>(client, something);
}
T Get<T>(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
return JsonConvert.DeserializeObject<T>(client.Execute(request).Content,
new JsonSerializerSettings
{
Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args)
{
args.ErrorContext.Error.Message.Dump();
args.ErrorContext.Handled = true;
}
});
}
void stuff(RestClient client)
{
client.BaseUrl = new Uri(BaseUrl + "Definitions");
RestRequest request = new RestRequest();
request.Method = Method.GET;
var definitions = JsonConvert.DeserializeObject<List<DefinitionDto>>(client.Execute(request).Content);
definitions.Where(d => d.DimensionGuid == new Guid("6EF6B1F7-A50C-4198-8866-140BB82E2DDA")).Dump("Definitions");
client.BaseUrl = new Uri(BaseUrl + "MDXScoreToCube");
var mdx = JsonConvert.DeserializeObject<List<MDXScoreToCubeDto>>(client.Execute(request).Content);
mdx.Dump("MDX");
client.BaseUrl = new Uri(BaseUrl + "Reports");
var reports = JsonConvert.DeserializeObject<List<ReportDto>>(client.Execute(request).Content);
reports.Dump("Reports");
var reportSetupUrl = new Uri(BaseUrl + "Reports/{0}/Setup");
reports.Where(r => r.Id == new Guid("a4a12e21-954b-4889-d5c8-08d71f2ff590")).ToList().ForEach(r =>
{
client.BaseUrl = new Uri(BaseUrl + $"Reports/{r.Id}");
var rpt = JsonConvert.DeserializeObject<ReportDto>(client.Execute(request).Content);
rpt.DefinitionIds.ForEach(d =>
{
client.BaseUrl = new Uri(BaseUrl + $"Defintions/{d}");
var definition = JsonConvert.DeserializeObject<List<DefinitionDto>>(client.Execute(request).Content);
definition.Dump($"Report {r.Name} Definition {d}");
});
});
}
// Define other methods and classes here
public class ReportInfo
{
public string Report { get; set; }
public string DimensionID { get; set; }
public string AttributeID { get; set; }
public string ParameterXML { get; set; }
internal XmlDocument doc;
public string Parameter { get; set; }
public ReportInfo(string parameterXML)
{
ParameterXML = parameterXML;
var parameterXml = ParameterXML = $"<root>{ParameterXML}</root>"
.RemoveAllNamespacesAsString()
.Replace("string>", "valueId>")
.Replace("<Value2 i:nil=\"true\" />", "<Value2 />")
.Replace("<_", "<").Replace("</_", "</")
.Replace("p5:nil=\"true\" xmlns:p5=\"http://www.w3.org/2001/XMLSchema-instance\"", "");
XmlDocument doc = new XmlDocument();
doc.LoadXml(parameterXml);
Parameter = JsonConvert.SerializeObject(
JsonConvert.DeserializeObject<dynamic>(
JsonConvert.SerializeXmlNode(doc.SelectSingleNode("root")
)
)
,
Newtonsoft.Json.Formatting.Indented);
}
}
public class StrataSphereMappingValues
{
public string HierarchyGUID { get; set; }
public string DimensionGUID { get; set; }
public List<string> values { get; set; }
public List<MappingValue> mappings { get; set; }
public List<string> hierarchyPaths { get; set; }
public StrataSphereMappingValues()
{
mappings = new List<MappingValue>();
}
}
public class MappingValue
{
public string id { get; set; }
public string displayHierarchyName { get; set; }
public string text { get; set; }
public string name { get; set; }
public List<object> attributeValues { get; set; }
public List<string> hierarchyPaths { get; set; }
public MappingValue()
{
attributeValues = new List<object>();
hierarchyPaths = new List<string>();
}
}
public enum eStrataSphereItemCategory
{
Report,
Dashboard
}
public enum StrataSphereReportEnum
{
Report,
DSCubeReport,
SQLReport,
ClientReport
}
public class ReportDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Author { get; set; }
public eStrataSphereItemCategory Category => eStrataSphereItemCategory.Report;
public string Tagline =>
$"Report | {Module} | {DateCreated.ToString("MMM-dd-YYYY")} | {DownloadCount} downloads";
public StrataSphereReportEnum ReportType { get; set; }
public string Module { get; set; }
public string MinJazzVersion { get; set; }
public string MaxJazzVersion { get; set; }
public string ReportSetupJson { get; set; }
public List<Guid> DefinitionIds { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
public int DownloadCount { get; set; }
public ReportDto()
{
ReportSetupJson = "{}";
DefinitionIds = new List<Guid>();
}
}
public class DefinitionDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Guid HierarchyGuid { get; set; }
public Guid DimensionGuid { get; set; }
public Guid AttributeGuid { get; set; }
public string HierarchyId { get; set; }
public string DimensionId { get; set; }
public string AttributeId { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
}
public enum MDXMemberIDTypeEnum
{
Attribute,
Name,
Text,
Id,
HierarchyPath
}
public enum MDXFormatTypeEnum
{
None,
MDX,
Hierarchy,
MDXMemberId
}
public class MDXScoreToCubeDto
{
public string OrgPin { get; set; }
public Guid DatabaseGuid { get; set; }
public string ScoreDimensionName { get; set; }
public string ScoreHierarchyName { get; set; }
public string CubeDimensionName { get; set; }
public string CubeHierarchyName { get; set; }
public MDXMemberIDTypeEnum MDXMemberIDType { get; set; }
public MDXFormatTypeEnum MDXFormatType { get; set; }
}
public class ValueIDArray
{
public List<string> valueId { get; set; }
}
public class DSCubeSearchCondition
{
public string FilterOp { get; set; }
public string SearchType { get; set; }
public string Value2 { get; set; }
public string Value { get; set; }
public ValueIDArray ValueIDArray { get; set; }
}
public class SearchConditions
{
public DSCubeSearchCondition DSCubeSearchCondition { get; set; }
}
public class DSCubeSearchParameterValue
{
public string ParameterGUID { get; set; }
public string ParameterValueGUID { get; set; }
public SearchConditions SearchConditions { get; set; }
}
public class Root
{
public DSCubeSearchParameterValue DSCubeSearchParameterValue { get; set; }
}
public class RootObject
{
public Root root { get; set; }
}
#region StrataSphereAdHocReportSetup
public interface IStrataSphereAdHocReportSectionItem
{
string Name { get; set; }
bool IsOnChartXAxis { get; set; }
bool IsOnChartYAxis { get; set; }
}
internal class StrataSphereAdHocReportAttribute : IStrataSphereAdHocReportSectionItem
{
public StrataSphereAdHocReportAttribute()
{
}
public string AttributeId { get; set; }
public string DimensionId { get; set; }
public int Index { get; set; }
public string Name { get; set; }
public IList<string> FilterMembers { get; set; }
public int VisibilityStatusValue { get; set; }
public bool ShowSubtotal { get; set; }
public bool IsOnChartXAxis { get; set; }
public bool IsOnChartYAxis { get; set; }
// section level filters
public List<object> Parameters { get; set; } = new List<object>();
//public List<StrataSphereAdHocReportParameter> Parameters { get; set; } = new List<StrataSphereAdHocReportParameter>();
}
internal class StrataSphereAdHocReportCalculation : IStrataSphereAdHocReportSectionItem
{
public StrataSphereAdHocReportCalculation()
{
}
public string Name { get; set; }
public string CalcType { get; set; }
public int DisplayOrder { get; set; }
public string DisplayFormat { get; set; }
public int ColumnWidth { get; set; }
public string CalculationJson { get; set; }
public string CssClass { get; set; }
public bool IsAttributeMember { get; set; }
public bool IsOnChartXAxis { get; set; }
public bool IsOnChartYAxis { get; set; }
public List<StrataSphereAdHocReportConditionalFormat> ConditionalFormats { get; set; } = new List<StrataSphereAdHocReportConditionalFormat>();
}
internal class StrataSphereAdHocReportConditionalFormat
{
public StrataSphereAdHocReportConditionalFormat()
{
}
public string Comment { get; set; }
public int DisplayOrder { get; set; }
public ReportTupleInfo ColumnTupleInfo { get; set; }
public string CssClass { get; set; }
public string ValueToCompareAsString { get; set; }
public int OperatorValue { get; set; }
}
internal class StrataSphereAdHocReportConfig
{
public string Title { get; set; }
public string Description { get; set; }
public string[] Colors { get; set; }
public AxisSetting AxisSettings { get; set; }
public string XType { get; set; }
public bool YAxisMultiSelect { get; set; }
public Guid XAxisSectionItemGuid { get; set; }
public List<Guid> YAxisSectionItemGuids { get; set; } = new List<Guid>();
public StrataSphereAdHocReportConfig(BaseConfig source)
{
if (source == null) return;
Title = source.Title;
Description = source.Description;
Colors = source.Colors;
AxisSettings = source.AxisSettings;
XType = source.XType;
YAxisMultiSelect = source.YAxisMultiSelect;
}
public BaseConfig GetChartConfig()
{
var chartConfig = default(BaseConfig);
/*
// Try decoding the xType by the name first
var asm = typeof(AreaConfig).Assembly;
var type = asm.GetType($"{asm.GetName().Name}.Reporting.ChartConfigs.{XType}");
if (type != null)
{
chartConfig = (BaseConfig)Activator.CreateInstance(type);
}
else // if that failed then use the hard coded selector, this is an issue if new types are supported
{
switch (XType)
{
case "AreaConfig":
chartConfig = new AreaConfig();
break;
case "BarConfig":
chartConfig = new BarConfig();
break;
case "BubbleConfig":
chartConfig = new BubbleConfig();
break;
case "ColumnConfig":
chartConfig = new ColumnConfig();
break;
case "ComboColumnAndLineConfig":
chartConfig = new ComboColumnAndLineConfig();
break;
case "ComboColumnAndLineWithSecondaryAxisConfig":
chartConfig = new ComboColumnAndLineWithSecondaryAxisConfig();
break;
case "DonutConfig":
chartConfig = new DonutConfig();
break;
case "LineConfig":
chartConfig = new LineConfig();
break;
case "PieConfig":
chartConfig = new PieConfig();
break;
case "ScatterConfig":
chartConfig = new ScatterConfig();
break;
case "SplineConfig":
chartConfig = new SplineConfig();
break;
case "StackedBarConfig":
chartConfig = new StackedBarConfig();
break;
case "StackedBarPercentConfig":
chartConfig = new StackedBarPercentConfig();
break;
case "StackedColumnConfig":
chartConfig = new StackedColumnConfig();
break;
case "StackedColumnPercentConfig":
chartConfig = new StackedColumnPercentConfig();
break;
}
}
*/
if (chartConfig == null) return chartConfig;
chartConfig.Title = Title;
chartConfig.Description = Description;
chartConfig.Colors = Colors;
chartConfig.AxisSettings = AxisSettings;
// if (chartConfig is XYConfig xyConfig)
// {
// xyConfig.XAxisSectionItemGuid = XAxisSectionItemGuid;
// xyConfig.YAxisSectionItemGuids.AddRange(YAxisSectionItemGuids);
// }
return chartConfig;
}
}
internal class StrataSphereAdHocReportDataSource
{
public StrataSphereAdHocReportDataSource()
{
}
public Guid DataSourceGuid { get; set; }
public string Name { get; set; }
public int DataSourceType { get; set; }
}
internal class StrataSphereAdHocReportMeasure : IStrataSphereAdHocReportSectionItem
{
public StrataSphereAdHocReportMeasure()
{
}
public string MeasureId { get; set; }
public string Name { get; set; }
public int Index { get; set; }
public string DisplayFormat { get; set; }
public int ColumnWidth { get; set; }
public bool IsOnChartXAxis { get; set; }
public bool IsOnChartYAxis { get; set; }
// section level filters
public List<StrataSphereAdHocReportParameter> Parameters { get; set; } = new List<StrataSphereAdHocReportParameter>();
public List<StrataSphereAdHocReportConditionalFormat> ConditionalFormats { get; set; } = new List<StrataSphereAdHocReportConditionalFormat>();
}
internal class StrataSphereAdHocReportSection
{
public StrataSphereAdHocReportSection()
{
}
public string Name { get; set; }
public bool IsOnColumn { get; set; }
public int DisplayOrder { get; set; }
public bool IsTimeRelative { get; set; }
public bool IsFinancialReportSectionHidable { get; set; }
public bool IsMergingRepeatHeader { get; set; }
public bool IsSpaceAbove { get; set; }
public bool IsHidden { get; set; }
public string DisplayLabel { get; set; }
public bool ShowSectionLabel { get; set; }
public bool ShowGrandTotal { get; set; }
public bool IsAutoNameFilter { get; set; }
public bool ShowMargin { get; set; }
public List<object> Attributes { get; set; } = new List<object>();
public List<object> Measures { get; set; } = new List<object>();
public List<object> Calculations { get; set; } = new List<object>();
}
internal class StrataSphereAdHocReportSetup
{
public string Style { get; set; }
public StrataSphereAdHocReportSortArgs SortArgs { get; set; }
public List<StrataSphereAdHocReportDataSource> DataSources { get; set; } = new List<StrataSphereAdHocReportDataSource>();
public StrataSphereAdHocReportConfig ChartConfig { get; set; } = null;
public List<StrataSphereAdHocReportSection> Sections { get; set; } = new List<StrataSphereAdHocReportSection>();
public List<StrataSphereAdHocReportParameter> Parameters { get; set; } = new List<StrataSphereAdHocReportParameter>();
public List<StrataSphereAdHocScoreDimensionInfo> ServiceLines { get; set; } =
new List<StrataSphereAdHocScoreDimensionInfo>();
}
public class StrataSphereAdHocReportSortArgs
{
public StrataSphereAdHocReportTupleInfo TupleInfo { get; set; }
public bool IsAscending { get; set; }
public int SortCount { get; set; }
public int Top { get; set; }
public bool IsTopPercent { get; set; }
public bool IsIncludeAllOthers { get; set; }
public StrataSphereAdHocReportSortArgs()
{
TupleInfo = new StrataSphereAdHocReportTupleInfo();
}
}
public class StrataSphereAdHocReportTupleInfo
{
public Dictionary<string, string> PartialRowTuple { get; set; }
public Dictionary<string, string> PartialColTuple { get; set; }
public string MainMeasureName { get; private set; }
public string RowMeasureName { get; set; }
public string ColMeasureName { get; set; }
public Guid ColMeasureGUID { get; set; }
public string FormatString { get; set; }
public int rowIndex { get; set; }
public int colIndex { get; set; }
public Guid ColumnSectionGUID { get; set; }
public IAdHocReportSectionMeasure MainMeasure { get; set; }
public StrataSphereAdHocReportTupleInfo()
{
PartialRowTuple = new Dictionary<string, string>();
PartialColTuple = new Dictionary<string, string>();
ColumnSectionGUID = Guid.Empty;
ColMeasureGUID = Guid.Empty;
}
public StrataSphereAdHocReportTupleInfo(ReportTupleInfo tupleInfo)
: this()
{
if (tupleInfo == null) return;
tupleInfo.PartialRowTuple.Keys.ToList()
.ForEach(key => PartialRowTuple.Add(key, tupleInfo.PartialRowTuple[key]));
tupleInfo.PartialColTuple.Keys.ToList()
.ForEach(key => PartialColTuple.Add(key, tupleInfo.PartialColTuple[key]));
//MainMeasure = tupleInfo.MainMeasure;
MainMeasureName = tupleInfo.MainMeasureName;
RowMeasureName = tupleInfo.RowMeasureName;
ColMeasureName = tupleInfo.ColMeasureName;
ColMeasureGUID = tupleInfo.ColMeasureGUID;
FormatString = tupleInfo.FormatString;
rowIndex = tupleInfo.rowIndex;
colIndex = tupleInfo.colIndex;
ColumnSectionGUID = tupleInfo.ColumnSectionGUID;
}
public static implicit operator ReportTupleInfo(StrataSphereAdHocReportTupleInfo tupleInfo)
{
if (tupleInfo == null) return null;
var result = new ReportTupleInfo
{
PartialRowTuple = new Dictionary<string, string>(),
PartialColTuple = new Dictionary<string, string>(),
MainMeasure = tupleInfo.MainMeasure?.CopyMeasure(),
RowMeasureName = tupleInfo.RowMeasureName,
ColMeasureName = tupleInfo.ColMeasureName,
ColMeasureGUID = tupleInfo.ColMeasureGUID,
FormatString = tupleInfo.FormatString,
rowIndex = tupleInfo.rowIndex,
colIndex = tupleInfo.colIndex,
ColumnSectionGUID = tupleInfo.ColumnSectionGUID
};
tupleInfo.PartialRowTuple.Keys.ToList()
.ForEach(key => result.PartialRowTuple.Add(key, tupleInfo.PartialRowTuple[key]));
tupleInfo.PartialColTuple.Keys.ToList()
.ForEach(key => result.PartialColTuple.Add(key, tupleInfo.PartialColTuple[key]));
return result;
}
}
internal interface IStrataReportParameter
{
string DimensionId { get; set; }
string AttributeId { get; set; }
}
internal abstract class StrataSphereAdHocReportParameter : IStrataReportParameter
{
protected StrataSphereAdHocReportParameter()
{
}
public string Name { get; set; }
public string DimensionId { get; set; }
public string AttributeId { get; set; }
public string MeasureId { get; set; }
public int DisplayOrder { get; set; }
public bool IsUserEditable { get; set; }
public bool IsAttributeParameter => string.IsNullOrWhiteSpace(MeasureId);
}
public class StrataSphereAdHocScoreDimensionInfo
{
public Guid DimensionGUID { get; set; }
public string FriendlyName { get; set; }
public string GlobalID { get; set; }
public string AttributeId { get; set; }
public string MDXMemberID { get; set; }
public bool IsRollup { get; set; }
internal Regex ServiceLineRegex = new Regex(@"^Service Line (\d)$", RegexOptions.IgnoreCase);
// internal string MDXMemberName => AnalysisServicesUtils.GetHierarchyMDXName("Patient Encounter",
// ServiceLineRegex.IsMatch(FriendlyName) && IsRollup
// ? $"{ServiceLineRegex.Replace(FriendlyName, "Service Line Rollup ${1}")}"
// : $"{FriendlyName}{(IsRollup ? " Rollup" : "")}");
internal string Name => $"Patient Encounter - {FriendlyName}{(IsRollup ? " Rollup" : "")}";
internal StrataSphereAdHocScoreDimensionInfo()
{
MDXMemberID = string.Empty;
IsRollup = false;
}
}
#endregion
#region Other Stuff
public interface IAdHocReportSectionMeasure //: IAdHocReportSectionItem
{
string ColumnName { get; set; }
string DisplayFormat { get; }
string CSSClass { get; }
List<Guid> LinkedSectionGUIDs { get; }
void Hide();
string MeasureID { get; }
bool IsPartial { get; }
bool IsAttributeMember { get; }
eAggregateFunction AggregationTypeEnum { get; }
IAdHocReportSectionMeasure CopyMeasure();
}
public interface ITGuid<T>
{
Guid Value { get; set; }
bool IsEmpty { get; set; }
}
public enum eClientReportSectionItemType
{
Attribute = 0,
Hierarchy = 1,
Measure = 2,
Calculation = 3
}
public enum eReportDrilldownStatus
{
None = 0,
Drilldown = 1,
Drillup = 2
}
public enum eClientReportVisibilityStatus
{
Hidden = 0,
CompletelyVisible = 1,
PartiallyVisible = 2
}
public enum eAggregateFunction
{
Sum = 0,
Count = 1,
Avg = 2,
Min = 3,
Max = 4,
None = 5
}
public interface IAdHocReportSectionAttribute //: IAdHocReportSectionItem
{
ITGuid<IAdHocReportSectionAttribute> AttributeGUIDTyped { get; }
string DimensionID { get; }
string AttributeID { get; }
bool ShowSubtotal { get; set; }
SortOrder SortOrder { get; }
eClientReportVisibilityStatus VisibilityStatus { get; set; }
eReportDrilldownStatus DrilldownStatus { get; set; }
string FilterMemberCSV { get; set; }
List<string> FilterMembers { get; set; }
List<string> FilterMembersVisible { get; }
}
public class ReportTupleInfo
{
public ReportTupleInfo()
{
this.PartialRowTuple = new Dictionary<string, string>();
this.PartialColTuple = new Dictionary<string, string>();
}
private Dictionary<string, string> _Tuple;
public Dictionary<string, string> Tuple
{
get
{
return _Tuple;
}
set { _Tuple = value; }
}
public Dictionary<string, string> PartialRowTuple { get; set; }
public Dictionary<string, string> PartialColTuple { get; set; }
public string MainMeasureName { get; private set; }
private IAdHocReportSectionMeasure _MainMeasure;
public IAdHocReportSectionMeasure MainMeasure
{
get { return _MainMeasure; }
set
{
_MainMeasure = value;
MainMeasureName = (value == null) ? string.Empty : value.ColumnName;
}
}
public string RowMeasureName { get; set; }
public string ColMeasureName { get; set; }
public Guid ColMeasureGUID { get; set; }
public string FormatString { get; set; }
public int rowIndex { get; set; }
public int colIndex { get; set; }
public Guid ColumnSectionGUID { get; set; }
}
public class AxisSetting
{
public string XAxisLabel { get; set; }
public string YAxisLabel { get; set; }
public double? YAxisLowerBound { get; set; }
public double? YAxisUpperBound { get; set; }
public double? YAxisTickInterval { get; set; }
public double? YAxisPlotLineValue { get; set; }
public bool ShowDataLabel { get; set; }
public override bool Equals(object obj)
{
var config = (AxisSetting)obj;
if (config == null) return false;
if (config.XAxisLabel != this.XAxisLabel) return false;
if (config.YAxisLabel != this.YAxisLabel) return false;
if (config.YAxisLowerBound != this.YAxisLowerBound) return false;
if (config.YAxisUpperBound != this.YAxisUpperBound) return false;
if (config.YAxisTickInterval != this.YAxisTickInterval) return false;
if (config.YAxisPlotLineValue != this.YAxisPlotLineValue) return false;
if (config.ShowDataLabel != this.ShowDataLabel) return false;
return true;
}
}
public abstract class BaseConfig
{
public abstract DataTable GetData(object report);
public abstract string Name { get; }
public string Title { get; set; }
public string Description { get; set; }
public string[] Colors { get; set; }
public AxisSetting AxisSettings { get; set; }
public virtual string IconName { get { return ""; } }
public virtual string XType { get { return ""; } }
public virtual string SectionName { get { return ""; } }
public virtual int ColumnNumber { get { return -1; } }
public virtual int RowNumber { get { return -1; } }
public virtual bool YAxisMultiSelect { get { return true; } }
protected BaseConfig()
{
this.Colors = new string[] { };
this.AxisSettings = new AxisSetting();
}
public override bool Equals(object obj)
{
var config = (BaseConfig)obj;
if (config == null) return false;
if (config.Title != Title || config.Description != Description) return false;
if (config.Colors.Length != Colors.Length) return false;
if (config.Colors.Any(p => !Colors.Contains(p))) return false;
if (!config.AxisSettings.Equals(this.AxisSettings)) return false;
if (config.GetType().Name != this.GetType().Name) return false;
return true;
}
}
#endregion
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,107 @@
<Query Kind="Program">
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<NuGetReference>Flurl</NuGetReference>
<NuGetReference>Flurl.Http</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Flurl</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
<Namespace>Flurl.Http</Namespace>
</Query>
private string baseUrl;
void Main()
{
baseUrl = "https://api-dev.sdt.local/StrataSphere.Web.API.Service//api/v1/";
GetDefinitions().Dump();
GetDefinitionsAsync().Dump();
}
// Define other methods and classes here
public async Task<IEnumerable<DefinitionDto>> GetDefinitionsAsync()
{
return await GetTAsync<DefinitionDto>("Definitions");
}
public async Task<IEnumerable<T>> GetTAsync<T>(string pathSegment)
{
var flurlRequest = baseUrl.AppendPathSegment(pathSegment).GetJsonAsync<IEnumerable<T>>();
//flurlRequest.Wait();
await flurlRequest;
while (!flurlRequest.IsCompleted)
{
if (flurlRequest.Exception != null) return new List<T>();
}
var result = flurlRequest.Result;
return result;
}
public IEnumerable<DefinitionDto> GetDefinitions()
{
return Task.Run(async () => GetDefinitionsAsync().Result).Result;
}
public class DefinitionDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Guid DimensionGuid { get; set; }
public Guid AttributeGuid { get; set; }
public string DimensionId { get; set; }
public string AttributeId { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
}
@@ -0,0 +1,72 @@
<Query Kind="Statements">
<Connection>
<ID>77b65bea-e766-4e3c-a1ed-c4c2534b6019</ID>
<Persist>true</Persist>
<Server>D0001-SQL-01.sdt.local</Server>
<Database>jazz dev master</Database>
<ShowServer>true</ShowServer>
</Connection>
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.ComponentModel.Composition</Namespace>
<Namespace>System.ComponentModel.Composition.Hosting</Namespace>
<Namespace>System.ComponentModel.Composition.Primitives</Namespace>
<Namespace>System.ComponentModel.Composition.ReflectionModel</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>System.Net.Http</Namespace>
<Namespace>System.Net.Http.Headers</Namespace>
<Namespace>System.Numerics</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
</Query>
Definitions
.OrderBy(d => d.ObjectType)
.ThenBy(d => d.Name)
.Dump();
@@ -0,0 +1,66 @@
<Query Kind="Expression">
<Connection>
<ID>463c2997-8a6a-4688-9575-6549e5215f7b</ID>
<Persist>true</Persist>
<Server>D0011-SQL-01.sdt.local</Server>
<Database>StrataSphere</Database>
<ShowServer>true</ShowServer>
</Connection>
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
</Query>
from ri in ReportItems
join rci in ReportCardItems on ri.ReportCardItemId equals rci.Id
orderby ri.ReportId, rci.ReportCardItemType, rci.Name
where (!(from rcm in ReportCardMatches where rcm.ReportCardItemId == ri.ReportCardItemId && rcm.DatabaseGuid == Guid.Parse("9BC301F9-66C3-48AA-81E7-114F88A449EA") select rcm).Any())
select new { ri.ReportId, rci.Id, rci.Name, rci.ReportCardItemType, rci.ReportType, rci.ReportCardItemDataJson }
+176
View File
@@ -0,0 +1,176 @@
<Query Kind="Program">
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<NuGetReference>RestSharp</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
<Namespace>RestSharp</Namespace>
<Namespace>System.Dynamic</Namespace>
</Query>
private string BaseUrl = "https://api-prod.sdt.local/StrataSphere.Web.API.Service/api/v1/";
void Main()
{
RestClient client = new RestClient();
var reports = GetList<ReportDto>(client, "Reports");
var setups = reports.ToList()
.Select(rpt => GetList(client, $"Reports\\{rpt.Id}\\Setup"));
var attributes = setups.SelectMany(s => (s.Sections as List<dynamic>).Select(x => (x.Attributes as List<dynamic>)));
//attributes.Dump();
var results = attributes
.SelectMany(a => a.Select(x => new AttributeInfo
{
DimensionId = x.DimensionId,
AttributeId = x.AttributeId,
Name = x.Name,
Parameters = (x.Parameters as List<dynamic>)
.ConvertAll(p => new AttributeInfo
{
DimensionId = p.DimensionId,
AttributeId = p.AttributeId,
MeasureId = p.MeasureId,
DisplayOrder = p.DisplayOrder,
Name = p.Name
}).OrderBy(p => p.DisplayOrder)
})).GroupBy(x => x.ToString(), (grp, data) => data.First())
.OrderBy(a => a.Name);
results.Dump();
}
public class AttributeInfo
{
public string DimensionId { get; set; }
public string AttributeId { get; set; }
public string MeasureId { get; set; }
public long DisplayOrder { get; set; } = 0;
public string Name { get; set; }
public IEnumerable<AttributeInfo> Parameters { get; set; }
public override bool Equals(object obj)
{
var test = obj as AttributeInfo;
if (test == null) return false;
return test.Name == Name && test.DimensionId == DimensionId && test.AttributeId == AttributeId;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
return $"{Name} {DimensionId} {AttributeId} {DisplayOrder} {(Parameters?.Aggregate("", (x, y) => $"{x} {y.ToString()}") ?? "")}";
}
}
dynamic GetList(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
var converter = new ExpandoObjectConverter();
return JsonConvert.DeserializeObject<ExpandoObject>(client.Execute(request).Content, converter);
}
IEnumerable<T> GetList<T>(RestClient client, string something)
{
return Get<List<T>>(client, something);
}
T Get<T>(RestClient client, string something)
{
client.BaseUrl = new Uri(BaseUrl + something);
RestRequest request = new RestRequest();
request.Method = Method.GET;
return JsonConvert.DeserializeObject<T>(client.Execute(request).Content);
}
public enum eStrataSphereItemCategory
{
Report,
Dashboard
}
public enum StrataSphereReportEnum
{
Report,
DSCubeReport,
SQLReport,
ClientReport
}
public class ReportDto
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Author { get; set; }
public eStrataSphereItemCategory Category => eStrataSphereItemCategory.Report;
public string Tagline =>
$"Report | {Module} | {DateCreated.ToString("MMM-dd-YYYY")} | {DownloadCount} downloads";
public StrataSphereReportEnum ReportType { get; set; }
public string Module { get; set; }
public string MinJazzVersion { get; set; }
public string MaxJazzVersion { get; set; }
public string ReportSetupJson { get; set; }
public List<Guid> DefinitionIds { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastModified { get; set; }
public int DownloadCount { get; set; }
public ReportDto()
{
ReportSetupJson = "{}";
DefinitionIds = new List<Guid>();
}
}
+239
View File
@@ -0,0 +1,239 @@
<Query Kind="Program">
<Connection>
<ID>77b65bea-e766-4e3c-a1ed-c4c2534b6019</ID>
<Persist>true</Persist>
<Server>D0001-SQL-11.sdt.local</Server>
<Database>jazz dev master Prod</Database>
<ShowServer>true</ShowServer>
</Connection>
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
</Query>
private string tableQuery = @"SELECT c.TABLE_SCHEMA, c.TABLE_NAME, c.COLUMN_NAME, c.DATA_TYPE
, CAST(CASE WHEN ccu.CONSTRAINT_NAME IS NULL THEN 0 ELSE 1 END AS BIT) IsPrimaryKey
FROM INFORMATION_SCHEMA.COLUMNS AS c
LEFT OUTER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc ON tc.TABLE_SCHEMA = c.TABLE_SCHEMA AND tc.TABLE_NAME = c.TABLE_NAME
LEFT OUTER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS ccu ON ccu.TABLE_SCHEMA = tc.TABLE_SCHEMA AND ccu.TABLE_NAME = tc.TABLE_NAME AND ccu.CONSTRAINT_NAME = tc.CONSTRAINT_NAME AND ccu.COLUMN_NAME = c.COLUMN_NAME
WHERE c.TABLE_SCHEMA in ('stratasphere')
AND (CASE c.TABLE_SCHEMA
WHEN 'stratasphere' THEN 1
ELSE
CASE WHEN c.TABLE_NAME IN ('DimCaseType', 'CaseTypeFamily', 'CaseTypeFamilyMapping', 'CaseTypeFamilyMappingAPRDRG', 'CaseTypeFamilyMappingICD10', 'CaseTypeFamilyMappingCPT', 'CaseTypeFamilyVersion')
THEN 1 ELSE 0 END END = 1)
AND c.DATA_TYPE NOT IN ('datetime','uniqueidentifier', 'timestamp')
AND NOT (c.COLUMN_NAME = 'RowID' and CAST(CASE WHEN ccu.CONSTRAINT_NAME IS NULL THEN 0 ELSE 1 END AS BIT) = 1)
AND tc.CONSTRAINT_TYPE = 'Primary Key'
ORDER BY c.TABLE_NAME, c.ORDINAL_POSITION";
private List<OrderByInformation> OrderByStatements;
private List<ColumnsToExclude> ColumnsToBeExcluded;
void Main()
{
OrderByStatements = new List<OrderByInformation>
{
new OrderByInformation{
TableName = "cci.InitiativeWorkflowHistory",
OrderBy = "\r\nOrder By OBJ.FromStep, OBJ.ToStep"
},
new OrderByInformation{
TableName = "cci.VariationEncounterSavingInfo",
OrderBy = "\r\nOrder By OBJ.EncounterRecordNumber, OBJ.PhysicianID"
},
new OrderByInformation{
TableName = "stratasphere.MDXScoreToCube",
OrderBy = "\r\nOrder By OBJ.OrgPin, OBJ.ScoreDimensionName, ScoreHierarchyName"
}
};
ColumnsToBeExcluded = new List<ColumnsToExclude> {
new ColumnsToExclude{
TableName = "stratasphere.MDXScoreToCube",
ColumnNames = new [] {"DateCreated", "DateLastModified"}
}
};
var conn = new Tuple<string, string>("D0011-SQL-01.sdt.local", "stratasphere");
var q = GetQueries(conn);
var connections = new ServerInstance[] {
new ServerInstance("D0011-SQL-01.sdt.local","stratasphere", q.Select(r => r.TableName).ToArray()),
new ServerInstance("E0001-SQL-11.sdt.local", "stratasphere", q.Select(r => r.TableName).ToArray() )
}.ToList();
var sql = string.Join("\r\n", q.Select(r => r.SqlSelect));
var dataLegacy = GetData(connections[0], sql);
var dataUpdate = GetData(connections[1], sql);
foreach (var dt in Enumerable.Range(0, dataLegacy.Tables.Count))
{
var legacy = dataLegacy.Tables[dt].Rows;
var update = dataUpdate.Tables[dt].Rows;
var idxCount = legacy.Count;
var compare = new List<Tuple<DataRow, DataRow>>();
foreach (var row in Enumerable.Range(0, idxCount))
{
var r = legacy[row];
if (row < update.Count)
{
var u = update[row];
var rJson = JsonConvert.SerializeObject(r.ItemArray);
var uJson = JsonConvert.SerializeObject(u.ItemArray);
if (rJson != uJson)
{
compare.Add(new Tuple<DataRow, DataRow>(r, u));
}
}
else
{
compare.Add(new Tuple<DataRow, DataRow>(r, null));
}
}
if (compare.Any())
{
compare.Dump(dataLegacy.Tables[dt].TableName, 2);
}
else
{
"No differences found in data".Dump(dataLegacy.Tables[dt].TableName);
}
}
}
// Define other methods and classes here
public class ServerInstance
{
public string Server { get; set; }
public string Database { get; set; }
public IEnumerable<string> TableNames { get; set; }
public ServerInstance(string server, string database, string[] tableNames)
{
Server = server;
Database = database;
TableNames = tableNames;
}
}
public class OrderByInformation
{
public string TableName { get; set; }
public string OrderBy { get; set; }
}
public class ColumnsToExclude
{
public string TableName { get; set; }
public IEnumerable<string> ColumnNames { get; set; }
}
public List<SqlInformation> GetQueries(Tuple<string, string> connection)
{
var server = connection.Item1;
var database = connection.Item2;
var sql = tableQuery;
var connStr = $"data source={server};initial catalog='{database}';persist security info=True;Integrated Security=SSPI;";
using (var conn = new SqlConnection(connStr))
{
var dataset = new DataTable();
var adapter = new SqlDataAdapter(sql, conn);
adapter.Fill(dataset);
var items = dataset.AsEnumerable().Select(r => r).ToList().ConvertAll(r => r.ItemArray)
.Select(r => new InformationSchema { schema = (string)r[0], table = (string)r[1], column = (string)r[2], datatype = (string)r[3], isPrimaryKey = (bool)r[4] })
.Where(r => !ColumnsToBeExcluded.SingleOrDefault(ctbe => ctbe.TableName == r.schemaTable)?.ColumnNames.Contains(r.column) ?? true)
.GroupBy(r => new { r.schema, r.table }, (t, c) =>
new SqlInformation
{
TableName = $"{t.schema}.{t.table}",
SqlSelect = "Select\r\n" + c.Aggregate("", (x, y) => $"{x}, obj.{y.column}\r\n").Substring(1) + $" FROM {t.schema}.{t.table} OBJ"
+ OrderByStatements.SingleOrDefault(obs => obs.TableName.Equals($"{t.schema}.{t.table}", StringComparison.CurrentCultureIgnoreCase))?.OrderBy ?? ""
+ ";"
})
.ToList();
return items;
}
}
public class SqlInformation
{
public string TableName { get; set; }
public string SqlSelect { get; set; }
}
public class InformationSchema
{
public string schema { get; set; }
public string table { get; set; }
public string column { get; set; }
public string datatype { get; set; }
public bool isPrimaryKey { get; set; }
public string schemaTable => $"{schema}.{table}";
}
public DataSet GetData(ServerInstance serverInstance, string sql)
{
var server = serverInstance.Server;
var database = serverInstance.Database;
var connStr = $"data source={server};initial catalog='{database}';persist security info=True;Integrated Security=SSPI;";
using (var conn = new SqlConnection(connStr))
{
var dataset = new DataSet();
var adapter = new SqlDataAdapter(sql, conn);
adapter.Fill(dataset);
var tableNames = serverInstance.TableNames;
var idx = 0;
foreach (var tableName in tableNames)
{
dataset.Tables[idx].TableName = tableName;
idx += 1;
}
return dataset;
}
}