1172 lines
34 KiB
C#
1172 lines
34 KiB
C#
<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 20190708.1</Database>
|
|
<ShowServer>true</ShowServer>
|
|
</Connection>
|
|
<Reference><ProgramFilesX64>\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/StrataSphere.Web.API.Service/api/v1/";
|
|
|
|
void Main()
|
|
{
|
|
RestClient client = new RestClient();
|
|
var definitions = GetList<DefinitionDto>(client, "Definitions");
|
|
var hierarchies = (from scoreHierarchy in ViewScoreHierarchy select new { scoreHierarchy.HierarchyGUID, scoreHierarchy.FriendlyName, scoreHierarchy.DimensionGUID}).ToList()
|
|
.Where(sh => definitions.Select(d => d.HierarchyGuid).Contains(sh.HierarchyGUID))
|
|
.GroupBy(sh => sh.HierarchyGUID, (grp, data) => new { HierarchyGUID = grp, DimensionGUID = data.First().DimensionGUID, FriendlyName = data.First().FriendlyName });
|
|
//179B6541-2285-4196-4209-08D7469CC7F2
|
|
definitions
|
|
//.Where(d => d.HierarchyId == "UB Revenue Code")
|
|
.Where(d => d.DimensionId == "Patient Encounter")
|
|
.OrderBy(d => d.DimensionId).ThenBy(d => d.AttributeId).ThenBy(d => d.Name).Dump("Definitions");
|
|
hierarchies.Dump("Hierarchies");
|
|
|
|
var mdx = GetList<MDXScoreToCubeDto>(client, "MDXScoreToCube");
|
|
mdx
|
|
.Where(m => m.OrgPin == "0430")
|
|
//.Where(m => m.CubeDimensionName.Contains("Patient"))
|
|
.OrderBy(m => m.ScoreHierarchyName)
|
|
.ThenBy(m => m.OrgPin).Dump("MDX Score to Cube");
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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
|
|
{
|
|
/// <summary>
|
|
/// Definition Guid in StrataSphere
|
|
/// </summary>
|
|
/// <example>00000000-0000-0000-0000-000000000000</example>
|
|
public Guid Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// The name of the report
|
|
/// </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 type of report (i.e. PatientPopulation, Metric)
|
|
/// </summary>
|
|
/// <example>PatientPopulation</example>
|
|
public Guid HierarchyGuid { get; set; }
|
|
|
|
/// <summary>
|
|
/// The type of report (i.e. PatientPopulation, Metric)
|
|
/// </summary>
|
|
/// <example>PatientPopulation</example>
|
|
public Guid DimensionGuid { get; set; }
|
|
|
|
/// <summary>
|
|
/// The Value of the Object Type
|
|
/// </summary>
|
|
/// <example>All Cause 30 Day Readmits</example>
|
|
public Guid AttributeGuid { get; set; }
|
|
|
|
/// <summary>
|
|
/// The string of the Definition's dimension Id
|
|
/// </summary>
|
|
/// <example>[Patient Encounter]</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; }
|
|
|
|
/// <summary>
|
|
/// When the definition was uploaded to StrataSphere
|
|
/// </summary>
|
|
public DateTime DateCreated { get; set; }
|
|
|
|
/// <summary>
|
|
/// When the definition was last updated in StrataSphere
|
|
/// </summary>
|
|
public DateTime DateLastModified { get; set; }
|
|
|
|
}
|
|
|
|
public enum MDXMemberIDTypeEnum
|
|
{
|
|
Attribute,
|
|
Name,
|
|
Text,
|
|
Id,
|
|
HierarchyPath
|
|
}
|
|
|
|
public enum MDXFormatTypeEnum
|
|
{
|
|
None,
|
|
MDX,
|
|
Hierarchy,
|
|
MDXMemberId
|
|
}
|
|
|
|
public class MDXScoreToCubeDto
|
|
{
|
|
/// <summary>
|
|
/// The orgpin or the item
|
|
/// </summary>
|
|
/// <example>0000</example>
|
|
public string OrgPin { get; set; }
|
|
|
|
/// <summary>
|
|
/// The database guid of the item
|
|
/// </summary>
|
|
/// <example>00000000-0000-0000-0000-000000000000</example>
|
|
public Guid DatabaseGuid { get; set; }
|
|
|
|
/// <summary>
|
|
/// The Score Dimension Name of the item
|
|
/// </summary>
|
|
/// <example>Patient Type Rollup</example>
|
|
public string ScoreDimensionName { get; set; }
|
|
|
|
/// <summary>
|
|
/// The Score Hierarchy Name of the item
|
|
/// </summary>
|
|
/// <example>Patient Type Rollup</example>
|
|
public string ScoreHierarchyName { get; set; }
|
|
|
|
/// <summary>
|
|
/// The Cube Dimension Name of the item
|
|
/// </summary>
|
|
/// <example>Patient Type</example>
|
|
public string CubeDimensionName { get; set; }
|
|
|
|
/// <summary>
|
|
/// The Cube Hierarchy Name of the item
|
|
/// </summary>
|
|
/// <example>Rollup</example>
|
|
public string CubeHierarchyName { get; set; }
|
|
|
|
/// <summary>
|
|
/// Indicates if the MDX should use the Attribute, Name, or Text value
|
|
/// </summary>
|
|
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 StrataSphereAdHocReportAttribute(IAdHocReportSectionAttribute attribute)
|
|
{
|
|
AttributeId = attribute.AttributeID;
|
|
DimensionId = attribute.DimensionID;
|
|
Index = attribute.DisplayOrder;
|
|
Name = attribute.Name;
|
|
FilterMembers = attribute.FilterMembers;
|
|
VisibilityStatusValue = (int)attribute.VisibilityStatus;
|
|
ShowSubtotal = attribute.ShowSubtotal;
|
|
}
|
|
|
|
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<StrataSphereAdHocReportParameter> Parameters { get; set; } = new List<StrataSphereAdHocReportParameter>();
|
|
}
|
|
|
|
internal class StrataSphereAdHocReportCalculation : IStrataSphereAdHocReportSectionItem
|
|
{
|
|
public StrataSphereAdHocReportCalculation()
|
|
{
|
|
}
|
|
|
|
public StrataSphereAdHocReportCalculation(IAdHocReportSectionCalculation calculation)
|
|
{
|
|
Name = calculation.Name;
|
|
CalcType = calculation.CalculationType.ID;
|
|
DisplayOrder = calculation.DisplayOrder;
|
|
ColumnWidth = calculation.ColumnWidth;
|
|
DisplayFormat = calculation.DisplayFormat;
|
|
CalculationJson = JsonConvert.SerializeObject(calculation.CalculationType);
|
|
CssClass = calculation.CSSClass;
|
|
IsAttributeMember = calculation.IsAttributeMember;
|
|
}
|
|
|
|
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 StrataSphereAdHocReportConditionalFormat(IAdHocConditionalFormat conditionalFormat)
|
|
{
|
|
DisplayOrder = conditionalFormat.DisplayOrder;
|
|
Comment = conditionalFormat.Comment;
|
|
ColumnTupleInfo = conditionalFormat.ColumnTupleInfo;
|
|
}
|
|
|
|
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 StrataSphereAdHocReportDataSource(IDataSourceLink dataSourceLink)
|
|
{
|
|
DataSourceGuid = dataSourceLink.DataSourceGUID;
|
|
Name = dataSourceLink.DataSourceProvider.Name;
|
|
DataSourceType = (int)dataSourceLink.DataSourceProvider.DataSourceType;
|
|
}
|
|
|
|
public Guid DataSourceGuid { get; set; }
|
|
public string Name { get; set; }
|
|
public int DataSourceType { get; set; }
|
|
}
|
|
|
|
internal class StrataSphereAdHocReportMeasure : IStrataSphereAdHocReportSectionItem
|
|
{
|
|
public StrataSphereAdHocReportMeasure()
|
|
{
|
|
|
|
}
|
|
|
|
public StrataSphereAdHocReportMeasure(IAdHocReportSectionMeasure measure)
|
|
{
|
|
MeasureId = measure.MeasureID;
|
|
Index = measure.DisplayOrder;
|
|
Name = measure.Name;
|
|
DisplayFormat = measure.DisplayFormat;
|
|
ColumnWidth = measure.ColumnWidth;
|
|
}
|
|
|
|
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 StrataSphereAdHocReportSection(IReportDataGenerationSection section)
|
|
{
|
|
Name = section.Name;
|
|
DisplayOrder = section.DisplayOrder;
|
|
IsOnColumn = section.IsOnColumn;
|
|
IsTimeRelative = section.IsTimeRelative;
|
|
IsFinancialReportSectionHidable = section.IsFinancialReportSectionHidable;
|
|
IsMergingRepeatHeader = section.IsMergingRepeatHeader;
|
|
IsSpaceAbove = section.IsSpaceAbove;
|
|
IsHidden = section.IsHidden;
|
|
DisplayLabel = section.DisplayText;
|
|
ShowSectionLabel = section.ShowSectionLabel;
|
|
ShowGrandTotal = section.ShowGrandTotal;
|
|
ShowMargin = section.ShowMargin;
|
|
}
|
|
|
|
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<StrataSphereAdHocReportAttribute> Attributes { get; set; } = new List<StrataSphereAdHocReportAttribute>();
|
|
|
|
public List<StrataSphereAdHocReportMeasure> Measures { get; set; } = new List<StrataSphereAdHocReportMeasure>();
|
|
|
|
public List<StrataSphereAdHocReportCalculation> Calculations { get; set; } = new List<StrataSphereAdHocReportCalculation>();
|
|
}
|
|
|
|
|
|
|
|
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 StrataSphereAdHocReportSortArgs(IReportDataGenerationSetup reportSetup)
|
|
: this()
|
|
{
|
|
if (reportSetup.SortArgs == null) return;
|
|
TupleInfo = new StrataSphereAdHocReportTupleInfo(reportSetup);
|
|
IsAscending = reportSetup.SortArgs.IsAscending;
|
|
SortCount = reportSetup.SortArgs.SortCount;
|
|
Top = reportSetup.SortArgs.Top;
|
|
IsTopPercent = reportSetup.SortArgs.IsTopPercent;
|
|
IsIncludeAllOthers = reportSetup.SortArgs.IsIncludeAllOthers;
|
|
}
|
|
|
|
public static implicit operator ReportSortArgs(StrataSphereAdHocReportSortArgs sortArgs)
|
|
{
|
|
var result = sortArgs.TupleInfo != null
|
|
? new ReportSortArgs(sortArgs.TupleInfo)
|
|
: new ReportSortArgs();
|
|
result.IsAscending = sortArgs.IsAscending;
|
|
result.SortCount = sortArgs.SortCount;
|
|
result.Top = sortArgs.Top;
|
|
result.IsTopPercent = sortArgs.IsTopPercent;
|
|
result.IsIncludeAllOthers = sortArgs.IsIncludeAllOthers;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
private IAdHocReportSectionMeasure _mainMeasure;
|
|
protected virtual IAdHocReportSectionMeasure InMemoryMeasure
|
|
{
|
|
get
|
|
{
|
|
if (_mainMeasure != null) return _mainMeasure;
|
|
_mainMeasure = new InMemoryReportMeasure
|
|
{
|
|
ColumnName = string.IsNullOrEmpty(RowMeasureName)
|
|
? RowMeasureName
|
|
: ColMeasureName
|
|
};
|
|
return _mainMeasure;
|
|
}
|
|
}
|
|
|
|
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 StrataSphereAdHocReportTupleInfo(IReportDataGenerationSetup reportSetup)
|
|
: this(reportSetup.SortArgs.TupleInfo)
|
|
{
|
|
if (reportSetup.SortArgs.TupleInfo?.MainMeasure == null) return;
|
|
switch (reportSetup)
|
|
{
|
|
case DSCubeReportSetup cubeReportSetup:
|
|
MainMeasure = cubeReportSetup.SortArgs.TupleInfo.MainMeasure as DSCubeReportSectionMeasure;
|
|
break;
|
|
case ClientReportSetup clientReportSetup:
|
|
MainMeasure = clientReportSetup.SortArgs.TupleInfo.MainMeasure as ClientReportSectionMeasure;
|
|
break;
|
|
default:
|
|
MainMeasure = InMemoryMeasure;
|
|
break;
|
|
}
|
|
switch (MainMeasure)
|
|
{
|
|
case DSCubeReportSectionMeasure cubeMeasure:
|
|
cubeMeasure.Re
|
|
portSetup = null;
|
|
break;
|
|
case ClientReportSectionMeasure clientMeasure:
|
|
clientMeasure.ReportSetup = null;
|
|
break;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Other Stuff
|
|
|
|
public interface IReportDataGenerationSection : IStrataTreeNode
|
|
{
|
|
bool IsDeleted { get; }
|
|
IReportDataGenerationSetup ReportSetup { get; }
|
|
ITGuid<IReportDataGenerationSection> ReportSectionGUIDTyped { get; }
|
|
Guid SectionGUID { get; }
|
|
string Name { get; }
|
|
|
|
bool IsOnColumn { get; }
|
|
int DisplayOrder { get; }
|
|
bool IsTimeRelative { get; }
|
|
|
|
bool IsFinancialReportSectionHidable { get; }
|
|
bool IsMergingRepeatHeader { get; }
|
|
bool IsSpaceAbove { get; }
|
|
|
|
void AddAttribute(IAdHocReportSectionAttribute attr);
|
|
bool RemoveAttribute(IAdHocReportSectionAttribute attr);
|
|
void RemoveAttributeAt(int attrIndex);
|
|
|
|
void AddMeasure(IAdHocReportSectionMeasure meas);
|
|
bool RemoveMeasure(IAdHocReportSectionMeasure meas);
|
|
void RemoveMeasureAt(int attrIndex);
|
|
|
|
void AddCalculation(IAdHocReportSectionCalculation calc);
|
|
bool RemoveCalculation(IAdHocReportSectionCalculation calc);
|
|
void RemoveCalculationAt(int calcIndex);
|
|
|
|
IEnumerable<IAdHocReportSectionCalculation> Calculations { get; }
|
|
IEnumerable<IAdHocReportSectionAttribute> Attributes { get; }
|
|
IEnumerable<IAdHocReportSectionMeasure> Measures { get; }
|
|
|
|
IEnumerable<string> GetAdditionalSelectColumns();
|
|
|
|
IEnumerable<CostMeasureFilter> GetCostMeasureFilter();
|
|
|
|
IList<IAdHocReportSectionAttribute> GetValidVisibleAttributes(bool isDrillDown);
|
|
void RefreshVisibilityStatuses(IAdHocReportSectionAttribute drilledAttr, eReportDrilldownStatus ddStatus);
|
|
|
|
List<IAdHocReportSectionMeasure> ChildMeasuresAndCalcs { get; }
|
|
List<IAdHocReportSectionMeasure> VisibleMeasuresAndCalcs { get; }
|
|
IAdHocReportSectionMeasure GetPrimaryMeasureForUseInCalculation();
|
|
|
|
List<IAdHocReportSectionItem> GetAllSectionItems { get; }
|
|
IEnumerable<IAdHocReportSectionAttribute> GetExtractAttributes();
|
|
List<Guid> GetAllSectionItemGUIDs();
|
|
|
|
bool HasParameters();
|
|
void RefreshDrilldownStatuses();
|
|
|
|
void HidePartiallyVisibleItems();
|
|
|
|
#region " Rendering "
|
|
|
|
bool IsHidden { get; }
|
|
bool ShowSectionLabel { get; }
|
|
|
|
bool ShowGrandTotal { get; set; }
|
|
string GrandTotalDisplayTextOverride { get; }
|
|
string GrandTotalDisplayFormatOverride { get; }
|
|
bool ShowMargin { get; }
|
|
|
|
string SectionLabelCSSClassName { get; }
|
|
|
|
#endregion
|
|
}
|
|
|
|
public class ReportTupleInfo
|
|
{
|
|
public ReportTupleInfo()
|
|
{
|
|
this.PartialRowTuple = new Dictionary<string, string>();
|
|
this.PartialColTuple = new Dictionary<string, string>();
|
|
}
|
|
|
|
[NonSerialized]
|
|
private IReportTupleFactory _TupleFactory;
|
|
public IReportTupleFactory TupleFactory
|
|
{
|
|
get { return _TupleFactory; }
|
|
set { _TupleFactory = value; }
|
|
}
|
|
|
|
private Dictionary<string, string> _Tuple;
|
|
public Dictionary<string, string> Tuple
|
|
{
|
|
get
|
|
{
|
|
if (_Tuple == null)
|
|
{
|
|
RefreshTuple();
|
|
}
|
|
return _Tuple;
|
|
}
|
|
set { _Tuple = value; }
|
|
}
|
|
|
|
[DataMember]
|
|
public Dictionary<string, string> PartialRowTuple { get; set; }
|
|
|
|
[DataMember]
|
|
public Dictionary<string, string> PartialColTuple { get; set; }
|
|
|
|
[DataMember]
|
|
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;
|
|
}
|
|
}
|
|
|
|
[DataMember]
|
|
public string RowMeasureName { get; set; }
|
|
|
|
[DataMember]
|
|
public string ColMeasureName { get; set; }
|
|
|
|
[DataMember]
|
|
public Guid ColMeasureGUID { get; set; }
|
|
|
|
[DataMember]
|
|
public string FormatString { get; set; }
|
|
|
|
[DataMember]
|
|
public int rowIndex { get; set; }
|
|
|
|
[DataMember]
|
|
public int colIndex { get; set; }
|
|
|
|
[DataMember]
|
|
public Guid ColumnSectionGUID { get; set; }
|
|
|
|
public Dictionary<string, string> RefreshTuple()
|
|
{
|
|
_Tuple = new Dictionary<string, string>();
|
|
if (PartialRowTuple != null)
|
|
{
|
|
_Tuple.MergeUnsafe(PartialRowTuple);
|
|
}
|
|
if (PartialColTuple != null)
|
|
{
|
|
_Tuple.Merge(PartialColTuple);
|
|
}
|
|
return _Tuple;
|
|
}
|
|
|
|
public ReportTupleInfo MakeCopy()
|
|
{
|
|
var copy = new ReportTupleInfo()
|
|
{
|
|
TupleFactory = this.TupleFactory,
|
|
PartialColTuple = new Dictionary<string, string>(this.PartialColTuple),
|
|
PartialRowTuple = new Dictionary<string, string>(this.PartialRowTuple),
|
|
MainMeasure = this.MainMeasure,
|
|
RowMeasureName = this.RowMeasureName,
|
|
ColMeasureName = this.ColMeasureName,
|
|
ColMeasureGUID = this.ColMeasureGUID,
|
|
ColumnSectionGUID = this.ColumnSectionGUID,
|
|
FormatString = this.FormatString,
|
|
rowIndex = this.rowIndex,
|
|
colIndex = this.colIndex
|
|
};
|
|
return copy;
|
|
}
|
|
|
|
public void MergeTuples(ReportTupleInfo tupleToMerge)
|
|
{
|
|
PartialColTuple = (Dictionary<string, string>)PartialColTuple.MergeCopy(tupleToMerge.PartialColTuple);
|
|
PartialRowTuple = (Dictionary<string, string>)PartialRowTuple.MergeCopy(tupleToMerge.PartialRowTuple);
|
|
RefreshTuple();
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (!(obj is ReportTupleInfo))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var y = (ReportTupleInfo)obj;
|
|
|
|
if (this.MainMeasure == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!this.MainMeasure.ID.Equals(y.MainMeasure.ID))
|
|
{
|
|
return false;
|
|
}
|
|
if (!this.Tuple.ValueEquals(y.Tuple))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
//not sure how else we can do GetHashCode without being super slow so we will need the base class decide
|
|
}
|
|
}
|
|
|
|
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 interface IAdHocReportSectionItem //: IDisplayOrder, IStrataTreeNode
|
|
{
|
|
Guid ReportSectionGUID { get; }
|
|
Guid ReportSectionItemGUID { get; }
|
|
|
|
string Name { get; set; }
|
|
string ColumnName { get; }
|
|
bool IsHidden { get; }
|
|
bool IsDeleted { get; }
|
|
|
|
eClientReportSectionItemType ItemType { get; }
|
|
void SetID(Guid newGUID);
|
|
|
|
int ColumnWidth { get; set; }
|
|
string DetailReportGUIDsCSV { get; }
|
|
Guid BeforeCopyGUID { get; set; }
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
#endregion |