private object ConvertConditionValue(string datatype, object v) { if (new string[] { "datetime" }.Contains(datatype.ToLower())) { return(DateTimeStd.IsDateTimeThen(v, "yyyy-MM-dd HH:mm:ss")); } else if (new string[] { "bit" }.Contains(datatype.ToLower())) { return(BoolStd.ConvertTo(v, 1, 0)); } else if (new string[] { "text", "picture", "file" }.Contains(datatype.ToLower())) { return(""); } else { return(v); } }
public override object patch(string id) { var report_name = ComFunc.nvl(PostDataD.report_name); var report_desc = ComFunc.nvl(PostDataD.report_desc); var tables = PostDataD.tables; var columns = PostDataD.columns; if (tables == null || !(tables is IEnumerable <object>)) { return(new { code = "failed", msg = "关联表信息不可为空或格式不正确" }); } if (columns == null || !(columns is IEnumerable <object>)) { return(new { code = "failed", msg = "报表栏位信息不可为空或格式不正确" }); } var tablelist = (IEnumerable <object>)tables; var columnlist = (IEnumerable <object>)columns; var mainicount = 0; var pre_table_name = ""; foreach (dynamic item in tablelist) { if (ComFunc.nvl(item.table_name) == "") { return(new { code = "failed", msg = "关联表信息数据格式不正确" }); } if (ComFunc.nvl(item.table_name) == pre_table_name) { return(new { code = "failed", msg = "不可有重复的表" }); } if (item.ref_coumns != null) { if (!(item.ref_columns is IEnumerable <object>)) { return(new { code = "failed", msg = "关联表信息数据格式不正确" }); } } if (BoolStd.IsNotBoolThen(item.is_main)) { mainicount++; } pre_table_name = ComFunc.nvl(item.table_name); } if (mainicount > 1) { return(new { code = "failed", msg = "关联表只可以有一个主表(即关联栏位描述为空)" }); } foreach (dynamic item in columnlist) { if (ComFunc.nvl(item.table_name) == "" || ComFunc.nvl(item.column_name) == "" || ComFunc.nvl(item.column_display) == "") { return(new { code = "failed", msg = "关联表信息数据格式不正确" }); } } var up = DB.NewDBUnitParameter(); BeginTrans(); if (!(from t in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE", "a") where t.ReportUID == id select t).IsExists(up)) { return(new { code = "failed", msg = "报表不存在" }); } if ((from t in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE", "a") where t.ReportName == report_name && t.ReportUID != id select t).IsExists(up)) { return(new { code = "failed", msg = "报表名称已存在" }); } var jsonexpress = buildQueryJSON(tablelist, columnlist); if (jsonexpress == null) { return(new { code = "failed", msg = "报表栏位信息或关联表信息不正确,无法生产报表表达式" }); } var uid = Guid.NewGuid().ToString(); DB.QuickUpdate(up, "EXTEND_REPORT_TEMPLATE", new { ReportName = report_name, ReportDesc = report_desc, QueryJSON = jsonexpress.ToJSONString(), last_id = TokenPayLoad.ID, last_name = TokenPayLoad["username"], last_ip = ClientInfo.IP, last_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, new { ReportUID = uid, }); DB.QuickDelete(up, "EXTEND_REPORT_TEMPLATE_TABLES", new { ReportUID = uid, }); foreach (dynamic item in tablelist) { var refcolumns = ""; if (((IEnumerable <object>)item.ref_columns).Count() > 0) { refcolumns = ((IEnumerable <object>)item.ref_columns).Aggregate((x, y) => (ComFunc.nvl(x) + "," + ComFunc.nvl(y))).ToString(); } DB.QuickInsert(up, "EXTEND_REPORT_TEMPLATE_TABLES", new { ReportUID = uid, TableName = item.table_name, ReferenceColumns = refcolumns, IsMain = BoolStd.ConvertTo(item.is_main, 1, 0), add_id = TokenPayLoad.ID, add_name = TokenPayLoad["username"], add_ip = ClientInfo.IP, add_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), last_id = TokenPayLoad.ID, last_name = TokenPayLoad["username"], last_ip = ClientInfo.IP, last_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); } DB.QuickDelete(up, "EXTEND_REPORT_TEMPLATE_COLUMNS", new { ReportUID = uid, }); foreach (dynamic item in columnlist) { DB.QuickInsert(up, "EXTEND_REPORT_TEMPLATE_COLUMNS", new { ReportUID = uid, TableName = item.table_name, ShowColumnName = item.column_name, ShowColumnDesc = item.column_display, add_id = TokenPayLoad.ID, add_name = TokenPayLoad["username"], add_ip = ClientInfo.IP, add_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), last_id = TokenPayLoad.ID, last_name = TokenPayLoad["username"], last_ip = ClientInfo.IP, last_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }); } CommitTrans(); return(new { code = "success", msg = "操作成功" }); }