public TableData Query(Excelreport entity) { var result = new TableData(); var data = _app.Find(EntityToExpression <Excelreport> .GetExpressions(entity)); GetData(data, result); result.count = data.Count(); return(result); }
public string Upd(Excelreport Table_entity) { try { _app.Upd(Table_entity); } catch (Exception ex) { Result.Status = false; Result.Message = ex.Message; } return(JsonHelper.Instance.Serialize(Result)); }
public TableData QueryData(int ReportId, string Filter) { var result = new TableData(); try { Excelreport excelreport = _unitWork.FindSingle <Excelreport>(u => u.Id == ReportId); var sql = excelreport.Sql; var sfilter = excelreport.Params; if (!string.IsNullOrEmpty(sfilter)) { if (string.IsNullOrEmpty(Filter)) { throw new Exception("请填写查询条件!"); } JObject json = null; json = JObject.Parse(Filter); JObject jsondefault = null; jsondefault = JObject.Parse(sfilter); foreach (var item in jsondefault) { var key = item.Key; if (!json.ContainsKey(key)) { throw new Exception("查询条件不正确!"); } } foreach (var item in json) { sql = sql.Replace(item.Key, item.Value.ToString()); } } var ds = _sqlWork.SelectGet(sql); result.data = ds.Tables[0]; result.count = ds.Tables[0].Rows.Count; result.code = 200; } catch (Exception ex) { result.code = 500; result.msg = ex.Message; } return(result); }
public void Ins(Excelreport entity) { string sql = entity.Sql; if (sql.ToLower().IndexOf("delete") >= 0 || sql.ToLower().IndexOf("update") >= 0 || sql.ToLower().IndexOf("insert") >= 0 || sql.ToLower().IndexOf(" table ") >= 0 || sql.ToLower().IndexOf(" database ") >= 0 || sql.ToLower().IndexOf(" procedure ") >= 0 || sql.ToLower().IndexOf(" trigger ") >= 0 || sql.ToLower().IndexOf(" view ") >= 0) { throw new Exception("SELECT '语句不合法, 报表只能输入SELECT语句!' 发生错误 "); } _app.Add(entity); }
public string GetTemplate() { var result = new TableData(); List <Excelreport> listExcelreport = new List <Excelreport>(); Excelreport entity = _app.FindSingle(u => u.Id > 0); if (entity != null) { listExcelreport.Add(entity); } else { listExcelreport.Add(new Excelreport()); } result.data = listExcelreport; result.count = listExcelreport.Count; return(JsonHelper.Instance.Serialize(result)); }
public Response ImportIn(IFormFile excelfile) { Response result = new Infrastructure.Response(); List <Excelreport> exp = imp.ConvertToModel <Excelreport>(excelfile); string sErrorMsg = ""; for (int i = 0; i < exp.Count; i++) { try { Excelreport e = exp[i]; e.Id = null; _app.Add(e); } catch (Exception ex) { sErrorMsg += "第" + (i + 2) + "行:" + ex.Message + "<br>"; result.Message = sErrorMsg; break; } } if (sErrorMsg.Equals(string.Empty)) { if (exp.Count == 0) { sErrorMsg += "没有发现有效数据, 请确定模板是否正确, 或是否有填充数据!"; result.Message = sErrorMsg; } else { result.Message = "导入完成"; } } else { result.Status = false; result.Message = result.Message; } return(result); }
public string Load(PageReq pageRequest, Excelreport entity) { return(JsonHelper.Instance.Serialize(_app.Load(pageRequest, entity))); }
public string Export(Excelreport entity) { return(JsonHelper.Instance.Serialize(_app.ExportData(entity))); }
public TableData Load(PageReq pageRequest, Excelreport entity) { return(_app.Load(pageRequest, entity)); }
public TableData ExportData(Excelreport entity) { return(_app.ExportData(entity)); }