// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { var options = FrameDLRObject.CreateInstance(); //Logic参数设定 options.BusinessAssemblyName = "RestAPISample"; options.WeixinHome = "weixinhome"; //EWRA自定义模块加载 options.RestAPIModuleName = typeof(MyWebModule).FullName; //Logic参数设定 options.RestAPILogicAssemblyName = "RestAPISample"; //RestAPI模块启用定义 options.RestAPILogicBaseType = typeof(MyRestLogic); //Tag模块启动定义 options.TagAssembly = "RestAPISample"; options.RestAPIMainVersion = "v1.0"; //默认起始路由 options.DefaultStartRoute = MyConfig.GetConfiguration("Server", "DefaultStartRoute"); //设置apidoc的路由 options.APIDocRoute = MyConfig.GetConfiguration("Server", "APIDocRoute"); //设置是否显示api doc options.IsShowRestAPIDoc = BoolStd.IsNotBoolThen(MyConfig.GetConfiguration("Server", "IsShowAPIDoc"), false); //设置中间件参数 options.MiddleWareOptionsType = typeof(MyWebOptions); app.UseWeixinEWRAMiddleWare((FrameDLRObject)options); }
protected override dynamic ParseCopyData(FrameDLRObject obj) { var rtn = FrameDLRObject.CreateInstance(); var table = ComFunc.nvl(obj.GetValue("$table")); var to_table = ComFunc.nvl(obj.GetValue("$to_table")); var if_not_exists = BoolStd.IsNotBoolThen(obj.GetValue("$if_not_exists"), false); var filter = obj.GetValue("$where"); var sql = "INSERT INTO #new_table_name##columns_to# SELECT #columns_from# FROM #table_name# #where#"; var not_exists_filter = $"NOT EXISTS(SELECT 1 FROM {to_table} #where#)"; var columns_to = ""; var columns_from = ""; var datacollection = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase); var where = ""; var not_exists_where = where; if (filter != null && filter is FrameDLRObject) { where = SqlWhere((FrameDLRObject)filter, datacollection); not_exists_where = where; } foreach (var k in obj.Keys.Where(w => !w.StartsWith("$"))) { columns_from += $",{ColumnFormat(k)} AS {ColumnFormat(ComFunc.nvl(obj.GetValue(k)))}"; columns_to += $",{ColumnFormat(ComFunc.nvl(obj.GetValue(k)))}"; not_exists_where = not_exists_where.Replace(k, ComFunc.nvl(obj.GetValue(k))); } columns_to = string.IsNullOrEmpty(columns_to) ? "" : $"({columns_to.Substring(1)})"; columns_from = string.IsNullOrEmpty(columns_from) ? "*" : columns_from.Substring(1); if (if_not_exists) { not_exists_filter = !string.IsNullOrEmpty(not_exists_where) ? not_exists_filter.Replace("#where#", $"WHERE {not_exists_where}") : not_exists_filter.Replace("#where#", ""); where = string.IsNullOrEmpty(where) ? not_exists_filter : where + " AND " + not_exists_filter; } where = !string.IsNullOrEmpty(where) ? "WHERE " + where : ""; sql = sql.Replace("#table_name#", table) .Replace("#new_table_name#", to_table) .Replace("#where#", where) .Replace("#columns_to#", columns_to) .Replace("#columns_from#", columns_from); rtn.sql = sql; rtn.table = table; rtn.data = datacollection; return(rtn); }
public override List <object> get() { SetCacheEnable(false); var up = DB.NewDBUnitParameter(); var list = (from t in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE", "a") select new { t.ReportUID, t.ReportName, t.ReportDesc, t.IsActive }).GetQueryList(up); return(list.Select((d) => { d.IsActive = BoolStd.IsNotBoolThen(d.IsActive); return d; }).ToList <object>()); }
protected override dynamic ParseCopyTable(FrameDLRObject obj) { var rtn = FrameDLRObject.CreateInstance(); var table = ComFunc.nvl(obj.GetValue("$table")); var to_table = ComFunc.nvl(obj.GetValue("$to_table")); var with_data = BoolStd.IsNotBoolThen(obj.GetValue("$with_data")); var sql = "CREATE TABLE #new_table_name# AS SELECT * FROM #table_name# #where#"; var where = ""; if (!with_data) { where = "1=2"; } sql = sql.Replace("#table_name#", table) .Replace("#new_table_name#", to_table) .Replace("#where#", where); rtn.sql = sql; rtn.table = table; return(rtn); }
protected override dynamic ParseCopyTable(FrameDLRObject obj) { var rtn = FrameDLRObject.CreateInstance(); var table = ComFunc.nvl(obj.GetValue("$table")); var to_table = ComFunc.nvl(obj.GetValue("$to_table")); var with_data = BoolStd.IsNotBoolThen(obj.GetValue("$with_data")); var sql = "SELECT * INTO #new_table_name# FROM #table_name# #where#"; var columns = ""; var where = ""; if (!with_data) { where = "WHERE 1=2"; } columns = string.IsNullOrEmpty(columns) ? "*" : columns; sql = sql.Replace("#table_name#", table) .Replace("#new_table_name#", to_table) .Replace("#where#", where); rtn.sql = sql; rtn.table = table; return(rtn); }
/// <summary> /// 构建报表查询的DBExpress表达式 /// </summary> /// <param name="tables">关联表信息,格式: ///[ /// { /// table_name:'关联表名', /// is_main:'是否为主表', /// ref_columns:['关联栏位描述,格式:{表名}.{栏位名称}'] /// } ///]</param> /// <param name="columns"> /// 报表栏位信息,格式: /// [ /// { /// table_name:'关联表名,不可为空', /// column_name:'栏位名称,不可为空', /// column_display:'表头显示名称,不可为空' /// } /// ] /// </param> /// <returns>返回为null的时候证明无法组合成表达式</returns> FrameDLRObject buildQueryJSON(IEnumerable <object> tables, IEnumerable <object> columns) { FrameDLRObject rtn = FrameDLRObject.CreateInstance(); rtn.SetValue("$acttype", "Query"); //找出主表,从表 var maintable = new List <dynamic>(); var subtable = new List <dynamic>(); var alianmap = new Dictionary <string, string>(); var index = 0; foreach (dynamic t in tables) { if (BoolStd.IsNotBoolThen(t.is_main)) { maintable.Add(t); } else { subtable.Add(t); } alianmap.Add(t.table_name, $"t{index}"); index++; } if (maintable.Count > 1) { return(null); } FrameDLRObject table = FrameDLRObject.CreateInstance(); table.SetValue(maintable.First().table_name, alianmap[maintable.First().table_name]); foreach (dynamic t in subtable) { var alian = alianmap[t.table_name]; if (t.ref_columns != null) { FrameDLRObject texpress = FrameDLRObject.CreateInstance(); texpress.SetValue("$as", alian); var ref_columns = ((IEnumerable <object>)t.ref_columns).Select(d => ComFunc.nvl(d)); FrameDLRObject joinexpress = FrameDLRObject.CreateInstance(); texpress.SetValue("$join", joinexpress); FrameDLRObject onexpress = FrameDLRObject.CreateInstance(); joinexpress.SetValue("$on", onexpress); foreach (var c in ref_columns) { var left_column = c.Split('=')[0].Trim(); var join_table = c.Split('=')[1].Trim().Split('.')[0].Trim(); var by_column = c.Split('=')[1].Trim().Split('.')[1].Trim(); var alian_join_table = alianmap[join_table]; onexpress.SetValue(left_column, $"#sql:{alian_join_table}.{by_column}"); } table.SetValue(t.table_name, texpress); } } rtn.SetValue("$table", table); foreach (dynamic item in columns) { var table_name = item.table_name; var column_name = item.column_name; if (!alianmap.ContainsKey(table_name)) { return(null); } rtn.SetValue(column_name, $"#sql:{alianmap[table_name]}.{column_name}"); } return(rtn); }
public override object get(string id) { SetCacheEnable(false); var up = DB.NewDBUnitParameter(); var s = from t in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE", "a") join t2 in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE_TABLES", "b") on t.reportuid equals t2.reportuid join t3 in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE_COLUMNS", "c") on new { t2.reportuid, t2.tablename } equals new { t3.reportuid, t3.tablename } where t.reportuid == id select t; if (!s.IsExists(up)) { return(new { code = "failed", msg = "报表不存在或未激活" }); } dynamic info = (from t in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE", "a") where t.reportuid == id select t).GetQueryList(up).First(); var tables = (from t in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE_TABLES", "a") where t.reportuid == id select new { t.TableName, t.IsMain, t.ReferenceColumns }).GetQueryList(up); foreach (var item in tables) { var c = ComFunc.nvl(item.GetValue("ReferenceColumns")); var clist = new List <object>(); if (c != "") { clist.AddRange(c.Split(',')); } item.SetValue("RefColumns", clist); item.Remove("ReferenceColumns"); item.SetValue("IsMain", BoolStd.IsNotBoolThen(item.GetValue("IsMain"))); } var columns = (from t in DB.LamdaTable(up, "EXTEND_REPORT_TEMPLATE_COLUMNS", "a") where t.reportuid == id select new { t.TableName, t.ShowColumnName, t.ShowColumnDesc }).GetQueryList(up); return(new { code = "success", msg = "", ReportUID = info.reportuid, ReportName = info.reportname, ReportDesc = info.reportdesc, IsActive = BoolStd.IsNotBoolThen(info.IsActive), Tables = tables, ShowColumns = from t in columns group t by new { TableName = t.GetValue("TableName") } into g select new { TableName = g.First().GetValue("TableName"), Columns = from tt in g select new { ColumnName = tt.GetValue("ShowColumnName"), ColumnDisplayDesc = tt.GetValue("ShowColumnDesc") } } }); }
object GetTableSchema() { var up = DB.NewDBUnitParameter(); SetCacheEnable(false); var rtn = new List <object>(); var list = (from t in DB.LamdaTable(up, "EXTEND_METADATA", "a") join t2 in DB.LamdaTable(up, "EXTEND_METADATA_COLUMNS", "b") on t.metauid equals t2.metauid join t3 in DB.LamdaTable(up, "EXTEND_METADATA_CATEGORY", "c").LeftJoin() on t.metacategoryno equals t3.categoryno orderby t.metaname, t2.sortnum, t2.metacolumnname ascending select new { uid = t.metauid, name = t.metaname, desc = t.metadesc, category_no = t3.categoryno, category_name = t3.categoryname, column_name = t2.metacolumnname, column_desc = t2.metacolumndesc, column_memo = t2.memo }).GetQueryList(up); var metagrouplist = from t in list group t by new { uid = t.GetValue("uid"), name = t.GetValue("name"), desc = t.GetValue("desc"), category_no = t.GetValue("category_no"), category_name = t.GetValue("category_name") } into g select new { uid = g.First().GetValue("uid"), name = g.First().GetValue("name"), desc = g.First().GetValue("desc"), category_no = g.First().GetValue("category_no"), category_name = g.First().GetValue("category_name"), columns = from gg in g select new { column_name = gg.GetValue("column_name"), column_desc = gg.GetValue("column_desc"), column_memo = gg.GetValue("column_memo") } }; rtn.AddRange(metagrouplist); var diclist = (from t in DB.LamdaTable(up, "EXTEND_DICTIONARY_TABLE", "a") orderby t.dic_name select new { uid = t.dic_uid, name = t.dic_name, desc = t.dic_desc, category_no = "DIC", category_name = "词典表", is_tree = t.istree }).GetQueryList(up); var tmp = false; var diccolumns = new dynamic[] { new { column_name = "code", column_desc = "编号", only_tree = false }, new{ column_name = "value", column_desc = "值", only_tree = false }, new{ column_name = "level", column_desc = "层级", only_tree = true }, new{ column_name = "p_code", column_desc = "父编号", only_tree = true } }; var dicgrouplist = from t in diclist select new { t.uid, t.name, t.desc, t.category_no, t.category_name, columns = (BoolStd.IsNotBoolThen(t.is_tree)) ? from gg in diccolumns select new { gg.column_name, gg.column_desc, column_memo = "" } : from gg in diccolumns where gg.only_tree == false select new { gg.column_name, gg.column_desc, column_memo = "" } }; rtn.AddRange(dicgrouplist); return(new { code = "success", msg = "", data = rtn }); }
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 = "操作成功" }); }
protected override dynamic ParseAlterColumn(FrameDLRObject obj) { var rtn = FrameDLRObject.CreateInstance(); var table = ""; var alter_add_template = @"Alter Table #table# Add(#column_name# #data_type# #default# #null#);"; var alter_modify_template = @"Alter Table #table# Modify(#column_name# #data_type# #null#);"; var alter_drop_template = @"Alter Table #table# Drop Column #column_name#;"; var alter_rename_template = @"Alter Table #table# Rename Column #column_name# To #new_column_name#;"; var alter_drop_add_template = @"Alter Table #table# Drop Column #column_name#; Alter Table #table# Add(#column_name# #data_type# #default# #null#);"; var sql = new StringBuilder(); var columns = new List <FrameDLRObject>(); table = ComFunc.nvl(obj.GetValue("$table")); foreach (var item in obj.Items.Where(d => d.Key.StartsWith("$") == false)) { FrameDLRObject col = (FrameDLRObject)item.Value; var column_name = item.Key; if (col != null) { var alter_action = ComFunc.nvl(col.GetValue("$alter_action")); var new_name = ComFunc.nvl(col.GetValue("$new_name")); var datatype = ComFunc.nvl(col.GetValue("$datatype")); var precision = IntStd.IsNotIntThen(col.GetValue("$precision"), -1); var scale = IntStd.IsNotIntThen(col.GetValue("$scale"), -1); var default_value = ComFunc.nvl(col.GetValue("$default")); var is_null = BoolStd.IsNotBoolThen(col.GetValue("$isnull"), true); switch (alter_action) { case "rename": if (new_name != "") { sql.AppendLine(alter_rename_template.Replace("#table#", table).Replace("#column_name#", column_name).Replace("#new_column_name#", new_name)); } break; case "add": sql.AppendLine(alter_add_template .Replace("#table#", table) .Replace("#column_name#", column_name) .Replace("#data_type#", datatype) .Replace("#null#", is_null ? "null" : "not null") .Replace("#default#", convertExpressDefault2DBDefault(default_value, datatype))); break; case "modify": sql.AppendLine(alter_modify_template .Replace("#table#", table) .Replace("#column_name#", column_name) .Replace("#data_type#", datatype) .Replace("#null#", is_null ? "null" : "not null")); break; case "drop": sql.AppendLine(alter_drop_template .Replace("#table#", table) .Replace("#column_name#", column_name)); break; case "drop_add": sql.AppendLine(alter_drop_add_template .Replace("#table#", table) .Replace("#column_name#", column_name) .Replace("#data_type#", datatype) .Replace("#null#", is_null ? "null" : "not null") .Replace("#default#", convertExpressDefault2DBDefault(default_value, datatype))); break; default: break; } } } rtn.sql = sql; rtn.table = table; return(rtn); }
protected override void OnUsed(ProxyManager ma, dynamic options) { var version = ComFunc.nvl(options.RestAPIMainVersion); var assemblyName = ComFunc.nvl(options.RestAPILogicAssemblyName); _is_show_api_log = BoolStd.IsNotBoolThen(options.IsShowRestAPIDoc, true); _api_doc_route = ComFunc.nvl(options.APIDocRoute) == "" ? _api_doc_route : ("/" + ComFunc.nvl(options.APIDocRoute)).Replace("//", "/"); _default_start_route = ComFunc.nvl(options.DefaultStartRoute) == "" ? _default_start_route : ("/" + ComFunc.nvl(options.DefaultStartRoute)).Replace("//", "/"); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前API文档是否加载的设定为{_is_show_api_log},如需要修改,请在调用ProxyManager.UseProxy中的options中设定该参数(IsShowRestAPIDoc类型为bool类型)"); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前API文档路由设定为{_api_doc_route},如需要修改,请在调用ProxyManager.UseProxy中的options中设定该参数(APIDocRoute类型为string类型)"); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前默认起始路由设定为{_default_start_route},如需要修改,请在调用ProxyManager.UseProxy中的options中设定该参数(DefaultStartRoute类型为string类型)"); Type logicType = null; if (assemblyName == "") { GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, $"{this.GetType().Name}加载Logic失败,原因:RestAPILogicAssemblyName为空,请在调用ProxyManager.UseProxy中的options中设定该参数(RestAPILogicAssemblyName为Logic所在的Assembly的Name)"); return; } if (Assembly.Load(new AssemblyName(assemblyName)) == null) { GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, $"{this.GetType().Name}加载Logic失败,原因:名为{assemblyName}的Assembly的程式集不存在,请在调用ProxyManager.UseProxy中的options中确定该参数(RestAPILogicAssemblyName为Logic所在的Assembly的Name)正确"); return; } if (options.RestAPILogicBaseType == null) { logicType = typeof(RestLogic); } else { if (options.RestAPILogicBaseType is string) { logicType = Type.GetType(ComFunc.nvl(options.RestAPILogicBaseType)); } else if (options.RestAPILogicBaseType is Type && ((Type)options.RestAPILogicBaseType).GetTypeInfo().IsSubclassOf(typeof(RestLogic))) { logicType = (Type)options.RestAPILogicBaseType; } else { logicType = typeof(RestLogic); } } //加载RestRouteContext if (options.RestRouteContext == null) { _rpcontext = new DefaultRestRouteContext(); } else { if (options.RestRouteContext is string) { var context = Activator.CreateInstance(Type.GetType(ComFunc.nvl(options.RestRouteContext))); if (context is ARestRouteContext) { _rpcontext = (ARestRouteContext)context; } else { _rpcontext = new DefaultRestRouteContext(); } } else if (options.RestRouteContext is ARestRouteContext) { _rpcontext = (ARestRouteContext)options.RestRouteContext; } else { _rpcontext = new DefaultRestRouteContext(); } } GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前RestRouteContext为{_rpcontext.GetType().Name},如需要修改,请继承ARestRouteContext,然后在options.RestRouteContext来指定对应的路由解析器"); _rpcontext.Load(assemblyName, version, logicType); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前加载的Logic的基类为{logicType.Name},如需要修改,请在调用ProxyManager.UseProxy中的options中设定该参数(RestAPILogicBaseType类型为Type类型或Type的Name,该Type必须为RestLogic的子类)"); GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前运行的API的主版本号为{_rpcontext.MainVersion},如需要修改,请在调用ProxyManager.UseProxy中的options中设定该参数(RestAPIMainVersion格式为:v+数字,如v1.1)"); //加载验证logic if (options.RestAPIAuthLogicType == null) { var assembly = Assembly.Load(new AssemblyName(assemblyName)); var searchAuth = assembly.GetTypes().Where(p => p.GetTypeInfo().IsSubclassOf(typeof(AuthorizationLogic))); if (searchAuth.Count() > 0) { _auth = searchAuth.First(); } else { _auth = typeof(AuthorizationLogic); } } else { if (options.RestAPIAuthLogicType is string) { _auth = Type.GetType(ComFunc.nvl(options.RestAPIAuthLogicType)); } else if (options.RestAPIAuthLogicType is Type && ((Type)options.RestAPIAuthLogicType).GetTypeInfo().IsSubclassOf(typeof(AuthorizationLogic))) { _auth = (Type)options.RestAPIAuthLogicType; } else { _auth = typeof(AuthorizationLogic); } } GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前请求验证用的的Logic的为{_auth.Name},如需要修改,请在{assemblyName}继承AuthenrizeLogic实现相关方法,或者使用options.RestAPIAuthLogicType来指定验证Logic类型"); //加载InvokeFilter if (options.RestInvokefilterLogicType == null) { var assembly = Assembly.Load(new AssemblyName(assemblyName)); var searchAuth = assembly.GetTypes().Where(p => p.GetTypeInfo().IsSubclassOf(typeof(RestInvokeFilterLogic))); if (searchAuth.Count() > 0) { _invokefilter = searchAuth.First(); } else { _invokefilter = typeof(RestInvokeFilterLogic); } } else { if (options.RestInvokefilterLogicType is string) { _invokefilter = Type.GetType(ComFunc.nvl(options.RestInvokefilterLogicType)); } else if (options.RestInvokefilterLogicType is Type && ((Type)options.RestInvokefilterLogicType).GetTypeInfo().IsSubclassOf(typeof(RestInvokeFilterLogic))) { _invokefilter = (Type)options.RestInvokefilterLogicType; } else { _invokefilter = typeof(RestInvokeFilterLogic); } } GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.INFO, $"{this.GetType().Name}:当前InvokeFilter用的的Logic的为{_invokefilter.Name},如需要修改,请在{assemblyName}继承RestInvokeFilterLogic实现相关方法,或者使用options.RestInvokefilterLogicType来指定验证Logic类型"); }
object ReportRetails_Users_Plat(string report_uid) { SetCacheEnable(false); string user_uid = ComFunc.nvl(TokenPayLoad["no"]); var up = DB.NewDBUnitParameter(); var list = (from t in DB.LamdaTable(up, "RetailSummaryPerDay", "a") where t.uid == report_uid select t).GetQueryList(up); if (list.Count <= 0) { return(new { code = "failed", msg = "没有该报表的资料" }); } dynamic info = list.First(); var dt = DateTimeStd.IsDateTimeThen(info.log_time, "yyyy-MM-dd"); var s = from t in DB.LamdaTable(up, "APPExchange", "a") join t2 in DB.LamdaTable(up, "UserInfo", "b").LeftJoin() on t.mobile equals t2.mobile where t2.recommend_uid == info.retail_uid && t.log_time >= $"{dt} 00:00:00" && t.log_time <= $"{dt} 23:59:59" select new { t.log_time, t.mobile, t2.name, t.is_deal, t.is_register, t.is_perfection, t.deal_amount }; var result = s.QueryByPage(up, "log_time desc"); var tdata = from t in result.QueryData <FrameDLRObject>() select new { log_time = DateTimeStd.IsDateTimeThen(t.log_time, "yyyy-MM-dd HH:mm:ss"), mobile = ComFunc.nvl(t.mobile), name = ComFunc.nvl(t.name).Length > 0 ? ComFunc.AESDecrypt(ComFunc.nvl(t.name)) : "", is_deal = BoolStd.IsNotBoolThen(t.is_deal), is_register = BoolStd.IsNotBoolThen(t.is_register), is_perfection = BoolStd.IsNotBoolThen(t.is_perfection), t.deal_amount }; return(new { code = "success", msg = "", total_count = result.TotalRow, page = result.CurrentPage, total_page = result.TotalPage, limit = result.Count_Of_OnePage, data = from t in tdata select new { t.log_time, mobile = ComFunc.nvl(t.mobile).Length > 3 ? $"{ ComFunc.nvl(t.mobile).Substring(0, 3)}***{ComFunc.nvl(t.mobile).Substring(ComFunc.nvl(t.mobile).Length - 2, 2)}" : "", name = $"{(ComFunc.nvl(t.name).Length > 0 ? ComFunc.nvl(t.name).Substring(0, 1) : "")}***", t.is_deal, t.is_register, t.is_perfection, t.deal_amount } }); }
object CreateTable() { string ids = ComFunc.nvl(PostDataD.id); BeginTrans(); var up = DB.NewDBUnitParameter(); var array = ids.Split(',').Where(p => ComFunc.nvl(p) != ""); foreach (var id in array) { var s = from t in DB.LamdaTable(up, "EXTEND_METADATA", "a") where t.metauid == id select t; var list = s.GetQueryList(up); if (!s.IsExists(up)) { return(false); } dynamic info = list.First(); bool islocked = BoolStd.IsNotBoolThen(info.islocked, false); if (islocked) { return(new { code = "failed", msg = "元数据表已锁定,不可进行操作" }); } bool iscreated = BoolStd.IsNotBoolThen(info.iscreated, false); if (iscreated) { return(new { code = "failed", msg = "元数据表已创建,不可进行操作" }); } if (DB.IsTableExists(up, info.metaname)) { return(new { code = "failed", msg = "元数据表已存在,不可进行操作" }); } } foreach (var id in array) { var s = from t in DB.LamdaTable(up, "EXTEND_METADATA", "a") where t.metauid == id select t; dynamic info = s.GetQueryList(up).First(); var columns = (from t in DB.LamdaTable(up, "EXTEND_METADATA_COLUMNS", "a") where t.metauid == id select t).GetQueryList(up); var schemas = columns.Select((p) => { dynamic dobj = p; bool tmp = false; var rtn = new TableColumn(); rtn.Name = dobj.MetaColumnName; rtn.DataType = dobj.MetaDataType; if (IntStd.IsInt(dobj.MetaDataPrecision)) { rtn.Precision = (int)dobj.MetaDataPrecision; } if (IntStd.IsInt(dobj.MetaDataScale)) { rtn.Scale = (int)dobj.MetaDataScale; } rtn.Default = dobj.MetaDataDefault; rtn.AllowNull = BoolStd.IsNotBoolThen(dobj.MetaAllowEmpty, false); rtn.IsPK = BoolStd.IsNotBoolThen(dobj.MetaIsPK, false); return(rtn); }).ToList(); schemas.AddRange(new TableColumn[] { new TableColumn() { Name = "sort_no", DataType = "int", Default = "0", IsPK = false, AllowNull = true }, new TableColumn() { Name = "add_id", DataType = "varchar", Precision = 50, IsPK = false, AllowNull = true }, new TableColumn() { Name = "add_name", DataType = "nvarchar", Precision = 100, IsPK = false, AllowNull = true }, new TableColumn() { Name = "add_ip", DataType = "varchar", Precision = 15, IsPK = false, AllowNull = true }, new TableColumn() { Name = "add_time", DataType = "datetime", IsPK = false, AllowNull = true }, new TableColumn() { Name = "last_id", DataType = "varchar", Precision = 50, IsPK = false, AllowNull = true }, new TableColumn() { Name = "last_name", DataType = "nvarchar", Precision = 100, IsPK = false, AllowNull = true }, new TableColumn() { Name = "last_ip", DataType = "varchar", Precision = 15, IsPK = false, AllowNull = true }, new TableColumn() { Name = "last_time", DataType = "datetime", IsPK = false, AllowNull = true } }); DB.CreateTable(up, info.metaname, schemas.ToArray()); s.Update(up, new { islocked = 1, iscreated = 1 }); } CommitTrans(); return(new { code = "success", msg = "操作成功" }); }