/// <summary> /// 根据sql、过滤条件获取数据源,sql必须含有服务名前缀,如: /// Cm:select * from dt_log /// local:select * from letter /// </summary> /// <param name="p_sql">带前缀的sql</param> /// <param name="p_filter"></param> /// <returns></returns> static async Task <Table> GetDataBySql(string p_sql, string p_filter = null) { if (string.IsNullOrEmpty(p_sql)) { return(null); } string[] info = p_sql.Trim().Split(':'); if (info.Length != 2 || string.IsNullOrEmpty(info[0]) || string.IsNullOrEmpty(info[1])) { throw new Exception("Sql格式不正确!" + p_sql); } Table data; string sql = string.IsNullOrEmpty(p_filter) ? info[1] : $"select * from ({info[1]}) a where {p_filter}"; if (info[0].ToLower() == "local") { data = AtState.Query(sql); } else { data = await new UnaryRpc(info[0], "Da.Query", sql, null).Call <Table>(); } return(data); }
void OnQueryLocal(object sender, Mi e) { Table tbl = AtState.Query("select * from ClientLog limit 1"); if (tbl.Count > 0) { _fv1.Data = tbl[0]; } else { Kit.Msg("本地库无数据!"); } }
void LoadLocalList() { _lv.Data = AtState.Query("select * from chatmember"); }