177 lines
6.1 KiB
C#
177 lines
6.1 KiB
C#
<Query Kind="Program">
|
|
<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>
|
|
<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>();
|
|
}
|
|
}
|