Last active
July 19, 2018 12:01
-
-
Save pczajkowski/e87c802371e86e564aac4d72b0554692 to your computer and use it in GitHub Desktop.
Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void GenerateReport<T>(string path, DateTime? dateFrom = null) | |
{ | |
IReport<T> reportObject = ReportFactory.CreateReport<T>(); | |
var report = reportObject.GetReport(_ctx, dateFrom); | |
reportObject.SaveReportAsCSV(report, path, _delimiter); | |
} | |
/// <summary> | |
/// Generate OrdersInfoBiWeekly Report and save it to given csv file. | |
/// </summary> | |
/// <param name="path"></param> | |
/// <param name="dateFrom"></param> | |
public void GenerateOrdersInfoBiWeeklyReport(string path, DateTime? dateFrom = null) | |
{ | |
GenerateReport<OrdersInfoBiWeekly>(path, dateFrom); | |
} | |
/// <summary> | |
/// Generate OrdersInfoBiWeekly Report and save it to given csv file. | |
/// </summary> | |
/// <param name="path"></param> | |
/// <param name="dateFrom"></param> | |
public void GenerateContentTypeInfoReport(string path, DateTime? dateFrom = null) | |
{ | |
GenerateReport<ContentTypeInfo>(path, dateFrom); | |
} | |
/// <summary> | |
/// Generate CostCenterInfo Report and save it to given csv file. | |
/// </summary> | |
/// <param name="path"></param> | |
/// <param name="dateFrom"></param> | |
public void GenerateCostCenterInfoReport(string path, DateTime? dateFrom = null) | |
{ | |
GenerateReport<CostCenterInfo>(path, dateFrom); | |
} | |
/// <summary> | |
/// Generate CustomerLanguageInfo Report and save it to given csv file. | |
/// </summary> | |
/// <param name="path"></param> | |
/// <param name="dateFrom"></param> | |
public void GenerateCustomerLanguageInfoReport(string path, DateTime? dateFrom = null) | |
{ | |
GenerateReport<CustomerLanguageInfo>(path, dateFrom); | |
} | |
/// <summary> | |
/// Generate JobInfo Report and save it to given csv file. | |
/// </summary> | |
/// <param name="path"></param> | |
/// <param name="dateFrom"></param> | |
public void GenerateJobInfoReport(string path, DateTime? dateFrom = null) | |
{ | |
GenerateReport<JobInfo>(path, dateFrom); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ReportFactory | |
{ | |
public static IReport<T> CreateReport<T>() | |
{ | |
if (typeof(T) == typeof(OrdersInfoBiWeekly)) | |
return (IReport<T>) new OrdersInfoBiWeekly(); | |
if (typeof(T) == typeof(ContentTypeInfo)) | |
return (IReport<T>) new ContentTypeInfo(); | |
if (typeof(T) == typeof(CostCenterInfo)) | |
return (IReport<T>) new CostCenterInfo(); | |
if (typeof(T) == typeof(CustomerLanguageInfo)) | |
return (IReport<T>) new CustomerLanguageInfo(); | |
if (typeof(T) == typeof(JobInfo)) | |
return (IReport<T>) new JobInfo(); | |
throw new NotImplementedException($"Creation of {typeof(T)} interface is not supported yet."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment