static void UpdateDataVersion(string p_ver) { if (!string.IsNullOrEmpty(p_ver)) { var ls = p_ver.Split(','); var tbl = AtState.Query("select id,ver from DataVersion"); if (tbl != null && tbl.Count > 0) { foreach (var row in tbl) { if (!ls.Contains($"{row[0]}+{row[1]}")) { // 删除版本号,未实际删除缓存数据,待下次用到时获取新数据! AtState.Exec($"delete from DataVersion where id='{row.Str(0)}'"); } } } } else { // 所有缓存数据失效 AtState.Exec("delete from DataVersion"); } }
/// <summary> /// 判断当前登录用户是否具有指定权限 /// </summary> /// <param name="p_id">权限ID</param> /// <returns>true 表示有权限</returns> public static async Task <bool> HasPrv(string p_id) { int cnt = AtState.GetScalar <int>("select count(*) from DataVersion where id='privilege'"); if (cnt == 0) { // 查询服务端 Dict dt = await new UnaryRpc( "cm", "UserRelated.GetPrivileges", UserID ).Call <Dict>(); // 记录版本号 var ver = new DataVersion(ID: "privilege", Ver: dt.Str("ver")); await AtState.Save(ver, false); // 清空旧数据 AtState.Exec("delete from UserPrivilege"); // 插入新数据 var ls = (List <string>)dt["result"]; if (ls != null && ls.Count > 0) { List <Dict> dts = new List <Dict>(); foreach (var prv in ls) { dts.Add(new Dict { { "prv", prv } }); } AtState.BatchExec("insert into UserPrivilege (prv) values (:prv)", dts); } } return(AtState.GetScalar <int>($"select count(*) from UserPrivilege where Prv='{p_id}'") > 0); }