private void SeperatesParam(SqlCommand cmd, P args, string Connectionstring) { var prefix = "DATA_"; if (args.Key.ToUpper().StartsWith(prefix)) { string key = args.Key.Remove(0, prefix.Length); if (args.Value is string str) { if (str != "[]" && str != "null" && str != "") { return; } if (str.StartsWith("{") && str.EndsWith("}") || str.StartsWith("[") && str.EndsWith("]")) { DataTable dt = SharedServices.JsonToDT(str); MappingDataTableWithUserDefined(conn: Connectionstring, dataTable: dt, userDefinedName: key); cmd.Parameters.AddWithValue(key, SharedServices.JsonToDT(str)); } } else if (args.Value is DataTable dataTable) { cmd.Parameters.AddWithValue( parameterName: key, value: MappingDataTableWithUserDefined(conn: Connectionstring, dataTable: dataTable, userDefinedName: key)); } } else { cmd.Parameters.AddWithValue(args.Key, args.Value); } }
public IActionResult DownloadExcelFromJsonfn(string fields, string data) { try { DataSet DsData = new DataSet(); DataTable DtData = SharedServices.JsonToDT(data); JArray ArryFields = JArray.Parse(fields); for (int i = 0; i < ArryFields.Count; i++) { DtData.Columns[i].ColumnName = ArryFields[i].ToString(); } for (int i = 0; i < ArryFields.Count; i++) { var name = ArryFields[i].ToString(); if (name.IndexOf(",hide") > -1) { DtData.Columns.Remove(name); } } DsData.Tables.Add(table: DtData); DownloadExcelModel excelModel = new DownloadExcelModel { DataSouece = DsData }; return(DownloadExcelFromDBfn(excelModel)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }