public int SaveReportTemplate(Dictionary <string, string> data) { //var intKeys = new string[] { // "Field1","Field2","Field3","Field4","Field5","Field6","XAxis1","XAxis2","XAxis3","YAxis1","YAxis2","YAxis3","ZAxis1","ZAxis2","ZAxis3" }; var stringKeys = new[] { "Name", "ReportType" }; var dateKeys = new[] { "StartDate", "EndDate" }; //var functionKeys = new string[]{ // "Field1Function","Field2Function","Field3Function","Field4Function","Field5Function","Field6Function","XAxis1Function","XAxis2Function", // "XAxis3Function","YAxis1Function","YAxis2Function","YAxis3Function","ZAxis1Function","ZAxis2Function","ZAxis3Function" //}; var reportTemplate1 = new ReportTemplate(); if (data != null) { if (data.Keys.Contains("NumberofRecords")) { reportTemplate1.NumberofRecords = Convert.ToInt32(data["NumberofRecords"]); data.Remove("NumberofRecords"); } if (data.Keys.Contains("OrderDirection")) { reportTemplate1.OrderDirection = data["OrderDirection"]; data.Remove("OrderDirection"); } } foreach (string key in stringKeys) { if (data != null) { if (data.Keys.Contains(key)) { if (!String.IsNullOrEmpty(data[key])) { reportTemplate1.GetType().GetProperty(key).SetValue(reportTemplate1, data[key]); } data.Remove(key); } } } foreach (string key in dateKeys) { if (data != null) { if (data.Keys.Contains(key)) { if (!String.IsNullOrEmpty(data[key])) { reportTemplate1.GetType().GetProperty(key).SetValue(reportTemplate1, Convert.ToDateTime(data[key])); } data.Remove(key); } } } _db.ReportTemplates.Add(reportTemplate1); _db.SaveChanges(); var reportTemplateId = reportTemplate1.ReportID; //if (data != null && data.Keys.Any()) // foreach (var key in data.Keys) // { // var reportField = new ReportField {ReportID = reportTemplateId}; // var value = data[key]; // var valueArray = value.Split(','); // if (valueArray.cou) // reportField.FieldId = Convert.ToInt32(valueArray[3]); // reportField.Func = valueArray[1]; // _db.ReportFields.Add(reportField); // } _db.SaveChanges(); return(reportTemplate1.ReportID); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings({"unchecked", "rawtypes"}) private com.opengamma.strata.report.ReportRunner<com.opengamma.strata.report.ReportTemplate> getReportRunner(com.opengamma.strata.report.ReportTemplate reportTemplate) private ReportRunner <ReportTemplate> getReportRunner(ReportTemplate reportTemplate) { // double-casts to achieve result type, allowing report runner to be used without external knowledge of template type if (reportTemplate is TradeReportTemplate) { return((ReportRunner)TradeReportRunner.INSTANCE); } else if (reportTemplate is CashFlowReportTemplate) { return((ReportRunner)CashFlowReportRunner.INSTANCE); } throw new System.ArgumentException(Messages.format("Unsupported report type: {}", reportTemplate.GetType().Name)); }