// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { CombinedFrequencyDomainService CFDS = new CombinedFrequencyDomainService(); HttpResponseMessage ReturnedObj = null; GadgetParameters GadgetParameters = null; ControllerCommon CommonClass = new ControllerCommon(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); JObject gadgetJSON = (JObject)value["gadget"]; CFDS = new CombinedFrequencyDomainService(); EwavCombinedFrequencyGadgetParameters CombinedParameters = new EwavCombinedFrequencyGadgetParameters(); CombinedParameters.CombineMode = (CombineModeTypes)Enum.Parse(typeof(CombineModeTypes), gadgetJSON["combinedmode"].ToString()); CombinedParameters.ShowDenominator = Convert.ToBoolean(gadgetJSON["showdenominator"].ToString()); CombinedParameters.SortHighToLow = Convert.ToBoolean(gadgetJSON["sort"].ToString()); CombinedParameters.TrueValue = (gadgetJSON["truevalue"].ToString().Trim().Length == 0 ? null : value["truevalue"].ToString()); GadgetParameters = new GadgetParameters(); GadgetParameters.DatasourceName = gadgetJSON["@DatasourceName"].ToString(); GadgetParameters.MainVariableName = gadgetJSON["mainVariable"].ToString(); GadgetParameters.InputVariableList = new Dictionary <string, string>(); GadgetParameters.InputVariableList.Add("tableName", gadgetJSON["@DatasourceName"].ToString()); GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); string groupVar = gadgetJSON["mainVariable"].ToString(); List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); Rules = CommonClass.ReadRules(value); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(gadgetJSON, true); DatatableBag dtBag = CFDS.GenerateCombinedFrequency(CombinedParameters, groupVar, GadgetParameters, dashboardFilters, Rules); ReturnedObj = new HttpResponseMessage() { Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(dtBag)) }; ReturnedObj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(ReturnedObj); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { ScatterDomainService ScatterDomainService = new Ewav.Web.Services.ScatterDomainService(); GadgetParameters GadgetParameters; ControllerCommon CommonClass = new ControllerCommon(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); Google.DataTable.Net.Wrapper.DataTable dt = null; JObject chartJSON = (JObject)value["chart"]; List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); GadgetParameters = new GadgetParameters(); GadgetParameters.DatasourceName = chartJSON["@DatasourceName"].ToString(); GadgetParameters.InputVariableList = new Dictionary <string, string>(); GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); Mapper Mapper = new Controllers.Mapper(); GadgetParameters.MainVariableName = chartJSON["xAxisVariable"].ToString(); GadgetParameters.CrosstabVariableName = chartJSON["yAxisVariable"].ToString(); Rules = CommonClass.ReadRules(value); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(chartJSON, true); dt = new Google.DataTable.Net.Wrapper.DataTable(); ScatterDataDTO ScatterDTO = ScatterDomainService.GenerateTable( GadgetParameters, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString); //if (ScatterDTO.RegresResults.Variables != null) //{ decimal coefficient = Convert.ToDecimal(ScatterDTO.RegresResults.Variables[0].Coefficient); decimal constant = Convert.ToDecimal(ScatterDTO.RegresResults.Variables[1].Coefficient); NumericDataValue newMaxValue = new NumericDataValue(); newMaxValue.IndependentValue = ScatterDTO.MaxValue.IndependentValue + 1; newMaxValue.DependentValue = (coefficient * ScatterDTO.MaxValue.IndependentValue) + constant; NumericDataValue newMinValue = new NumericDataValue(); newMinValue.IndependentValue = ScatterDTO.MinValue.IndependentValue - 1; newMinValue.DependentValue = (coefficient * ScatterDTO.MinValue.IndependentValue) + constant; //} dt.AddColumn(new Column(ColumnType.Number, "X", "X")); dt.AddColumn(new Column(ColumnType.Number, GadgetParameters.MainVariableName, GadgetParameters.MainVariableName)); dt.AddColumn(new Column(ColumnType.Number, GadgetParameters.CrosstabVariableName, GadgetParameters.CrosstabVariableName)); Row r = dt.NewRow(); r.AddCellRange(new Cell[] { new Cell(newMinValue.IndependentValue), new Cell(newMinValue.DependentValue), new Cell(null) } ); dt.AddRow(r); r = dt.NewRow(); r.AddCellRange(new Cell[] { new Cell(newMaxValue.IndependentValue), new Cell(newMaxValue.DependentValue), new Cell(null) } ); dt.AddRow(r); foreach (var item in ScatterDTO.DataValues) { r = dt.NewRow(); r.AddCellRange(new Cell[] { new Cell(item.IndependentValue), new Cell(null), new Cell(item.DependentValue) } ); dt.AddRow(r); } var obj = new HttpResponseMessage() { Content = new StringContent(dt.GetJson()) }; obj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(obj); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { LinearRegressionDomainService LinearRegressionDomainService = new LinearRegressionDomainService(); GadgetParameters GadgetParameters; ControllerCommon CommonClass = new ControllerCommon(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); JObject gadgetJSON = (JObject)value["gadget"]; List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); GadgetParameters = new GadgetParameters(); GadgetParameters.DatasourceName = gadgetJSON["@DatasourceName"].ToString(); GadgetParameters.InputVariableList = new Dictionary <string, string>(); GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); Mapper Mapper = new Controllers.Mapper(); Rules = CommonClass.ReadRules(value); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(gadgetJSON, true); List <string> columnNames = new List <string>(); Dictionary <string, string> inputVariableList = Mapper.MapJSONToRegressionInputVariableList(gadgetJSON); foreach (KeyValuePair <string, string> kvp in inputVariableList) { if (kvp.Value.ToLower().Equals("unsorted") || kvp.Value.ToLower().Equals("dependvar") || kvp.Value.ToLower().Equals("weightvar") || kvp.Value.ToLower().Equals("matchvar")) { columnNames.Add(kvp.Key); } else if (kvp.Value.ToLower().Equals("discrete")) { columnNames.Add(kvp.Key); } } List <DictionaryDTO> inputDtoList = new List <DictionaryDTO>(); inputDtoList = Mapper.MapDictToList(inputVariableList); LinRegressionResults LinRegressionResults = LinearRegressionDomainService.GetRegressionResult( GadgetParameters, columnNames, inputDtoList, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString); LinRegressionResults = Mapper.FormatLinRegressionResults(LinRegressionResults); var obj = new HttpResponseMessage() { Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(LinRegressionResults))//dt.GetJson()) }; obj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(obj); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { FrequencyDomainService FrequencyDomainService = new FrequencyDomainService(); GadgetParameters GadgetParameters; ControllerCommon CommonClass = new ControllerCommon(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); JObject gadgetJSON = (JObject)value["gadget"]; List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); GadgetParameters = new GadgetParameters(); GadgetParameters.DatasourceName = gadgetJSON["@DatasourceName"].ToString(); GadgetParameters.MainVariableName = gadgetJSON["mainVariable"].ToString(); GadgetParameters.InputVariableList = new Dictionary <string, string>(); if (gadgetJSON["sort"] != null && gadgetJSON["sort"].ToString() == "highlow") { GadgetParameters.InputVariableList.Add("sort", "highlow"); GadgetParameters.ShouldSortHighToLow = true; } else { GadgetParameters.ShouldSortHighToLow = false; } GadgetParameters.InputVariableList.Add("tableName", gadgetJSON["@DatasourceName"].ToString()); GadgetParameters.InputVariableList.Add("freqvar", gadgetJSON["mainVariable"].ToString()); GadgetParameters.InputVariableList.Add("allvalues", gadgetJSON["allValues"].ToString()); GadgetParameters.InputVariableList.Add("freqVar", gadgetJSON["mainVariable"].ToString()); GadgetParameters.InputVariableList.Add("showconflimits", gadgetJSON["showConfLimits"].ToString()); GadgetParameters.InputVariableList.Add("showcumulativepercent", gadgetJSON["showCumulativePercent"].ToString()); GadgetParameters.InputVariableList.Add("includemissing", gadgetJSON["includeMissing"].ToString()); GadgetParameters.InputVariableList.Add("maxrows", "200"); GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); if (gadgetJSON["strataVariable"].ToString().Trim().Length > 0) { List <MyString> StrataList = new List <MyString>(); MyString strata = new MyString(); strata.VarName = gadgetJSON["strataVariable"].ToString(); StrataList.Add(strata); GadgetParameters.StrataVariableList = StrataList; } Rules = CommonClass.ReadRules(value); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(gadgetJSON, true); List <FrequencyResultData> FrequencyResultData = FrequencyDomainService.GenerateFrequencyTable(GadgetParameters, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString); foreach (var item in FrequencyResultData) { foreach (var row in item.FrequencyControlDtoList) { if ((row.FreqVariable.Split('/').Length > 2 && row.FreqVariable.Split('/').Length < 4) || // Valid Combos:- enumerator/enumerator/enumerator, enumerator-enumerator-enumerator , (row.FreqVariable.Split('-').Length > 2 && row.FreqVariable.Split('-').Length < 4)) //Invalid Combos:- enumerator/enumerator, enumerator/enumerator/enumerator/enumerator, enumerator-enumerator, enumerator-enumerator-enumerator-enumerator { row.FreqVariable = DateTime.Parse(row.FreqVariable, CultureInfo.CurrentUICulture).ToShortDateString(); } else { row.FreqVariable = row.FreqVariable; } } } FrequencyInfoAndMetaInfo AllInfo = new FrequencyInfoAndMetaInfo(); AllInfo.FreqResult = FrequencyResultData; AllInfo.GadgetParameters = GadgetParameters; var obj = new HttpResponseMessage() { Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(AllInfo))//dt.GetJson()) }; obj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(obj); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { EpiCurveDomainService EpiCurveDomainService = new EpiCurveDomainService(); Google.DataTable.Net.Wrapper.DataTable dt = null; HttpResponseMessage ReturnedObj = null; GadgetParameters GadgetParameters = new GadgetParameters(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); ControllerCommon CommonClass = new ControllerCommon(); JObject chartJSON = (JObject)value["chart"]; List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); bool byEpiWeek = false; GadgetParameters.MainVariableName = string.Empty; GadgetParameters.WeightVariableName = string.Empty; GadgetParameters.StrataVariableNames = new List <string>(); GadgetParameters.CrosstabVariableName = string.Empty; GadgetParameters.InputVariableList = new Dictionary <string, string>(); GadgetParameters.ShouldSortHighToLow = false; GadgetParameters.DatasourceName = chartJSON["@DatasourceName"].ToString(); string strataVariable = string.Empty; GadgetParameters.MainVariableName = chartJSON["dateVariable"].ToString(); GadgetParameters.InputVariableList = new Dictionary <string, string>(); // tablename really menas DatasourName GadgetParameters.InputVariableList.Add("tableName", chartJSON["@DatasourceName"].ToString()); GadgetParameters.ShouldUseAllPossibleValues = false; GadgetParameters.InputVariableList.Add("xaxisstart", chartJSON["xAxisStartValue"].ToString()); GadgetParameters.InputVariableList.Add("xaxisend", chartJSON["xAxisEndValue"].ToString()); GadgetParameters.InputVariableList.Add("isdatecolumnnumeric", "false"); GadgetParameters.InputVariableList.Add("dateinterval", chartJSON["dateInterval"].ToString()); GadgetParameters.CrosstabVariableName = chartJSON["caseStatusVariable"].ToString(); GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(chartJSON, true); Rules = CommonClass.ReadRules(value); if (GadgetParameters.InputVariableList.ContainsKey("isdatecolumnnumeric")) { byEpiWeek = bool.Parse(GadgetParameters.InputVariableList["isdatecolumnnumeric"]); } DatatableBag data = EpiCurveDomainService.GetEpiCurveData(GadgetParameters, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString, byEpiWeek, chartJSON["dateVariable"].ToString(), chartJSON["caseStatusVariable"].ToString()); dt = new Google.DataTable.Net.Wrapper.DataTable(); dt.AddColumn(new Column(ColumnType.String, "FreqVariable", "FreqVariable")); for (int i = 1; i < data.ColumnNameList.Count; i++) { dt.AddColumn(new Column(ColumnType.Number, "FrequencyColumn" + i, data.ColumnNameList[i].VarName.ToString())); } foreach (var item in data.RecordList) { //if (item.Fields[1].VarName.ToString().Length > 0) //{ Row r = dt.NewRow(); for (int i = 0; i < data.ColumnNameList.Count; i++) { string dateValue = item.Fields[i].VarName.ToString(); DateTime result = DateTime.Now; if (DateTime.TryParse(dateValue, out result)) { switch (chartJSON["dateInterval"].ToString().ToLower()) { case "hours": dateValue = result.ToString("g"); break; case "months": dateValue = result.ToString("MMM yyyy"); break; case "years": dateValue = result.ToString("yyyy"); break; default: //"days" dateValue = result.ToShortDateString(); break; } } r.AddCell(new Cell(dateValue)); } //); dt.AddRow(r); //} } ReturnedObj = new HttpResponseMessage() { Content = new StringContent(dt.GetJson()) }; ReturnedObj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(ReturnedObj); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { XYChartDomainService XYChartDomainService = new XYChartDomainService(); Google.DataTable.Net.Wrapper.DataTable dt = null; HttpResponseMessage ReturnedObj = null; GadgetParameters GadgetParameters = new GadgetParameters(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); ControllerCommon CommonClass = new ControllerCommon(); JObject chartJSON = (JObject)value["chart"]; List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); dt = new Google.DataTable.Net.Wrapper.DataTable(); Rules = CommonClass.ReadRules(value); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(chartJSON, true); GadgetParameters.DatasourceName = chartJSON["@DatasourceName"].ToString(); string strataVariable = string.Empty; if (chartJSON["chartType"].ToString().ToLower() == "stackedcolumn") { GadgetParameters.MainVariableName = chartJSON["xAxisVariable"].ToString(); strataVariable = chartJSON["yAxisVariable"].ToString(); } else if (chartJSON["chartType"].ToString().ToLower() == "pareto") { GadgetParameters.ShouldSortHighToLow = true; GadgetParameters.MainVariableName = chartJSON["singleVariable"].ToString(); strataVariable = chartJSON["strataVariable"].ToString(); } else { GadgetParameters.MainVariableName = chartJSON["singleVariable"].ToString(); strataVariable = chartJSON["strataVariable"].ToString(); } GadgetParameters.InputVariableList = new Dictionary <string, string>(); GadgetParameters.WeightVariableName = chartJSON["weightVariable"].ToString(); GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); if (strataVariable.Trim().Length > 0) { List <MyString> StrataList = new List <MyString>(); MyString strata = new MyString(); strata.VarName = strataVariable.ToString(); // chartJSON["strataVariable"].ToString(); StrataList.Add(strata); GadgetParameters.StrataVariableList = StrataList; } List <FrequencyResultData> FrequencyResultDataList = XYChartDomainService.GenerateFrequencyTable(GadgetParameters, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString); double runningPercent = 0, max = 0; foreach (var item in FrequencyResultDataList) { foreach (var row in item.FrequencyControlDtoList) { if ((row.FreqVariable.Split('/').Length > 2 && row.FreqVariable.Split('/').Length < 4) || // Valid Combos:- enumerator/enumerator/enumerator, enumerator-enumerator-enumerator , (row.FreqVariable.Split('-').Length > 2 && row.FreqVariable.Split('-').Length < 4)) //Invalid Combos:- enumerator/enumerator, enumerator/enumerator/enumerator/enumerator, enumerator-enumerator, enumerator-enumerator-enumerator-enumerator { row.FreqVariable = DateTime.Parse(row.FreqVariable, CultureInfo.CurrentUICulture).ToShortDateString(); } else { row.FreqVariable = row.FreqVariable; } if (chartJSON["chartType"].ToString().ToLower() == "pareto") //this.chartTypeEnum == XYControlChartTypes.Pareto) { max = max + CommonClass.SafeParsetoDou(row.FrequencyColumn); //.SafeParsetoDou(); } } } if (FrequencyResultDataList.Count > 1) { dt.AddColumn(new Column(ColumnType.String, "FreqVariable", "FreqVariable")); var DtoCount = FrequencyResultDataList.Count; for (int i = 0; i < DtoCount; i++) { var columnName = FrequencyResultDataList[i].FrequencyControlDtoList[0].NameOfDtoList; columnName = columnName.Split('=')[1].ToString(); dt.AddColumn(new Column(ColumnType.Number, columnName, columnName)); } for (int i = 0; i < FrequencyResultDataList[0].FrequencyControlDtoList.Count; i++) { Row r = dt.NewRow(); r.AddCell( new Cell(FrequencyResultDataList[0].FrequencyControlDtoList[i].FreqVariable) ); for (int j = 0; j < DtoCount; j++) { r.AddCell( new Cell(FrequencyResultDataList[j].FrequencyControlDtoList[i].FrequencyColumn) ); } dt.AddRow(r); } } else { dt.AddColumn(new Column(ColumnType.String, "FreqVariable", "FreqVariable")); dt.AddColumn(new Column(ColumnType.Number, "FrequencyColumn", FrequencyResultDataList[0].FrequencyControlDtoList[0].NameOfDtoList)); if (chartJSON["chartType"].ToString().ToLower() == "pareto") // if chart is Pareto { dt.AddColumn(new Column(ColumnType.Number, "mean", "mean")); } foreach (EwavFrequencyControlDto Frequencydto in FrequencyResultDataList[0].FrequencyControlDtoList) { Row r = dt.NewRow(); r.AddCellRange(new Cell[] { new Cell(Frequencydto.FreqVariable), new Cell(Frequencydto.FrequencyColumn) //, } ); if (chartJSON["chartType"].ToString().ToLower() == "pareto")// if chart is Pareto { double meanValue = CommonClass.CalculateMean(Frequencydto.FrequencyColumn, max, runningPercent); meanValue = Math.Round(meanValue, 4); r.AddCell( new Cell(meanValue) ); runningPercent = CommonClass.SafeParsetoDou(meanValue.ToString()); } dt.AddRow(r); } } ReturnedObj = new HttpResponseMessage() { Content = new StringContent(dt.GetJson()) //Newtonsoft.Json.JsonConvert.SerializeObject(clientDto))//FrequencyResultData.FrequencyControlDtoList)) }; // return resultAsStr; ReturnedObj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(ReturnedObj); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { MeansDomainService MeansDomainService = new MeansDomainService(); GadgetParameters GadgetParameters; ControllerCommon CommonClass = new ControllerCommon(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); JObject gadgetJSON = (JObject)value["gadget"]; List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); GadgetParameters = new GadgetParameters(); GadgetParameters.DatasourceName = gadgetJSON["@DatasourceName"].ToString(); GadgetParameters.MainVariableName = gadgetJSON["mainVariable"].ToString(); GadgetParameters.InputVariableList = new Dictionary <string, string>(); GadgetParameters.InputVariableList.Add("tableName", gadgetJSON["@DatasourceName"].ToString()); GadgetParameters.InputVariableList.Add("meansvar", gadgetJSON["mainVariable"].ToString()); GadgetParameters.MainVariableName = gadgetJSON["mainVariable"].ToString(); GadgetParameters.InputVariableList.Add("weightvar", gadgetJSON["weightVariable"].ToString()); GadgetParameters.WeightVariableName = gadgetJSON["weightVariable"].ToString(); GadgetParameters.InputVariableList.Add("freqVar", gadgetJSON["mainVariable"].ToString()); GadgetParameters.InputVariableList.Add("crosstabvar", gadgetJSON["crosstabVariable"].ToString()); GadgetParameters.CrosstabVariableName = gadgetJSON["crosstabVariable"].ToString(); GadgetParameters.ShouldIncludeFullSummaryStatistics = true; if (Convert.ToBoolean(gadgetJSON["showANOVA"].ToString()) == true) { GadgetParameters.InputVariableList.Add("showanova", "true"); } else { GadgetParameters.InputVariableList.Add("showanova", "false"); } GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); if (gadgetJSON["strataVariable"].ToString().Trim().Length > 0) { List <MyString> StrataList = new List <MyString>(); MyString strata = new MyString(); strata.VarName = gadgetJSON["strataVariable"].ToString(); StrataList.Add(strata); GadgetParameters.StrataVariableList = StrataList; } Rules = CommonClass.ReadRules(value); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(gadgetJSON, true); string crosstabvar = gadgetJSON["crosstabVariable"].ToString(); List <FrequencyResultData> FrequencyResultData = null; FrequencyAndCrossTable FrequencyAndCrossTable = null; if (crosstabvar.Length > 0) { FrequencyAndCrossTable = MeansDomainService.GenerateCrossTableWithFrequencyTable(GadgetParameters, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString); FrequencyResultData = FrequencyAndCrossTable.FrequencyTable; } else { FrequencyResultData = MeansDomainService.GenerateFrequencyTable(GadgetParameters, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString); } foreach (var item in FrequencyResultData) { foreach (var row in item.FrequencyControlDtoList) { if ((row.FreqVariable.Split('/').Length > 2 && row.FreqVariable.Split('/').Length < 4) || // Valid Combos:- enumerator/enumerator/enumerator, enumerator-enumerator-enumerator , (row.FreqVariable.Split('-').Length > 2 && row.FreqVariable.Split('-').Length < 4)) //Invalid Combos:- enumerator/enumerator, enumerator/enumerator/enumerator/enumerator, enumerator-enumerator, enumerator-enumerator-enumerator-enumerator { row.FreqVariable = DateTime.Parse(row.FreqVariable, CultureInfo.CurrentUICulture).ToShortDateString(); } else { row.FreqVariable = row.FreqVariable; } } } FrequencyInfoAndMetaInfo AllInfo = new FrequencyInfoAndMetaInfo(); if (crosstabvar.Length > 0) { FrequencyAndCrossTable.FrequencyTable = FrequencyResultData; AllInfo.FreqResult = FrequencyAndCrossTable; } else { AllInfo.FreqResult = FrequencyResultData; } AllInfo.GadgetParameters = GadgetParameters; var jsonresult = Newtonsoft.Json.JsonConvert.SerializeObject(AllInfo).Replace("NaN", "null"); // JSON doesnt accept NaN token. It would make it invalid JSON. var obj = new HttpResponseMessage() { Content = new StringContent(jsonresult)//dt.GetJson()) }; obj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(obj); }
// POST api/<controller> public HttpResponseMessage Post([FromBody] JObject value) { MapClusterDomainService MapClusterDomainService = new MapClusterDomainService(); GadgetParameters GadgetParameters; ControllerCommon CommonClass = new ControllerCommon(); List <EwavRule_Base> Rules = new List <EwavRule_Base>(); JObject gadgetJSON = (JObject)value["gadget"]; List <EwavDataFilterCondition> dashboardFilters = new List <EwavDataFilterCondition>(); GadgetParameters = new GadgetParameters(); GadgetParameters.ShouldIncludeFullSummaryStatistics = true; GadgetParameters.ShouldIncludeMissing = false; GadgetParameters.ShouldSortHighToLow = false; GadgetParameters.ShouldUseAllPossibleValues = false; GadgetParameters.DatasourceName = gadgetJSON["@DatasourceName"].ToString(); //GadgetParameters.MainVariableName = gadgetJSON["mainVariable"].ToString(); GadgetParameters.StrataVariableNames = new List <string>(); //GadgetParameters.UseAdvancedDataFilter = CommonClass.AdvancedDataFilterString; GadgetParameters.TableName = CommonClass.GetDatabaseObject(GadgetParameters.DatasourceName); GadgetParameters.InputVariableList = new Dictionary <string, string>(); GadgetParameters.InputVariableList.Add("lonx", gadgetJSON["longitude"].ToString()); GadgetParameters.InputVariableList.Add(gadgetJSON["longitude"].ToString(), "listfield"); GadgetParameters.InputVariableList.Add("laty", gadgetJSON["latitude"].ToString()); GadgetParameters.InputVariableList.Add(gadgetJSON["latitude"].ToString(), "listfield"); GadgetParameters.InputVariableList.Add(gadgetJSON["stratifyby"].ToString(), "listfield"); if (gadgetJSON["stratifyby"].ToString().Trim().Length > 0) { List <MyString> StrataList = new List <MyString>(); MyString strata = new MyString(); strata.VarName = gadgetJSON["stratifyby"].ToString(); StrataList.Add(strata); GadgetParameters.StrataVariableList = StrataList; } Rules = CommonClass.ReadRules(value); dashboardFilters = CommonClass.GetFilters(value); GadgetParameters.GadgetFilters = CommonClass.GetFilters(gadgetJSON, true); List <PointDTOCollection> PDTOList = MapClusterDomainService.GetMapValues(GadgetParameters, dashboardFilters, Rules, CommonClass.AdvancedDataFilterString); var obj = new HttpResponseMessage() { Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(PDTOList)) }; obj.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(obj); }