private int GetAuthType(Guid authSourceFid) { int dataCnt = new MenuDAL().GetCounts("and [VALID_FLAG] <> 0 and [NEED_AUTH] = 1 and [FID] = '" + authSourceFid + "'"); if (dataCnt > 0) { return(1); } dataCnt = new MenuActionDAL().GetCounts("and [VALID_FLAG] <> 0 and [NEED_AUTH] = 1 and [FID] = '" + authSourceFid + "'"); if (dataCnt > 0) { return(2); } dataCnt = new ReportDAL().GetCounts("and [VALID_FLAG] <> 0 and [IS_AUTH] = 1 and [FID] = '" + authSourceFid + "'"); if (dataCnt > 0) { return(3); } dataCnt = new ChartDAL().GetCounts("and [VALID_FLAG] <> 0 and [IS_AUTH] = 1 and [FID] = '" + authSourceFid + "'"); if (dataCnt > 0) { return(4); } return(0); }
static string ChartTest() { IConnectionDAL connDAL = new ConnectionDAL(); Conn conn = connDAL.GetConnById(1); ChartDAL chartDAL = new ChartDAL(); //Chart chart = chartDAL.GetChartById(1); DataTable chartTable = chartDAL.GetChartTableById(1); ITestData testData = new TestData(); DataTable currencyTable = testData.GetCurrencyTableById(); //C3JSLine line = new C3JSLine(currencyTable, chartDAL.CurrentChart.ChartScript); //string json = line.Generate("CurrencyType", "Currency"); //return json; return(""); }
/// <summary> /// 获取所有需要授权的项目,其中IS_AUTH=TRUE表示已经授权 /// </summary> /// <param name="roleFid"></param> /// <returns></returns> public List <RoleAuthInfo> GetRoleAuthList(Guid roleFid) { ///需要授权的菜单 List <MenuInfo> menus = new MenuDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///需要授权的功能项 List <MenuActionInfo> menuactions = new MenuActionDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///功能项 List <ActionInfo> actions = new ActionDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///需要授权的报表 List <ReportInfo> reports = new ReportDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///需要授权的图表 List <ChartInfo> charts = new ChartDAL().GetList("and [VALID_FLAG] <> 0", string.Empty); ///角色对应已授权的项目 List <RoleAuthInfo> roleauths = new RoleAuthDAL().GetList("and [ROLE_FID] = '" + roleFid + "' and [IS_AUTH] <> 0 and [VALID_FLAG] <> 0", string.Empty); List <RoleAuthInfo> list = new List <RoleAuthInfo>(); ///菜单 foreach (var item in menus) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; info.AuthSourceName = item.MenuName + "|" + item.MenuNameCn; info.AuthType = 1; info.AuthTypeName = "菜单"; info.DisplayOrder = item.DisplayOrder.GetValueOrDefault(); if (item.NeedAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 1); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = item.ParentMenuFid.GetValueOrDefault(); list.Add(info); } ///功能 foreach (var item in menuactions) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; var action = actions.FirstOrDefault(d => d.Fid == item.ActionFid); if (action == null) { continue; } info.AuthSourceName = action.ActionName + "|" + action.ActionNameCn; info.AuthType = 2; info.AuthTypeName = "功能"; info.DisplayOrder = item.ActionOrder.GetValueOrDefault(); if (item.NeedAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 2); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = item.MenuFid.GetValueOrDefault(); var menuinfo = list.FirstOrDefault(d => d.AuthType == 1 && d.AuthSourceFid == item.MenuFid); if (menuinfo == null) { continue; } list.Add(info); } RoleAuthInfo reportauth = new RoleAuthInfo(); reportauth.AuthSourceFid = Guid.Parse("2238F7AD-9196-4B53-A0D0-81460FDA1F4C"); reportauth.AuthSourceName = "REPORT|报表"; reportauth.AuthType = 1; reportauth.AuthTypeName = "菜单"; reportauth.IsAuth = true; reportauth.DisplayOrder = int.MaxValue - 1; reportauth.ParentSourceFid = Guid.Empty; list.Add(reportauth); ///报表 foreach (var item in reports) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; info.AuthSourceName = item.NameEn + "|" + item.Name; info.AuthType = 3; info.AuthTypeName = "报表"; if (item.IsAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 3); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = reportauth.AuthSourceFid.GetValueOrDefault(); list.Add(info); } RoleAuthInfo chartauth = new RoleAuthInfo(); chartauth.AuthSourceFid = Guid.Parse("6E714DD6-2D41-45AE-88C2-433EEF1973E9"); chartauth.AuthSourceName = "CHART|图表"; chartauth.AuthType = 1; chartauth.AuthTypeName = "菜单"; chartauth.IsAuth = true; chartauth.DisplayOrder = int.MaxValue; chartauth.ParentSourceFid = Guid.Empty; list.Add(chartauth); ///图表 foreach (var item in charts) { RoleAuthInfo info = new RoleAuthInfo(); info.AuthSourceFid = item.Fid; info.AuthSourceName = item.NameEn + "|" + item.Name; info.AuthType = 4; info.AuthTypeName = "图表"; if (item.IsAuth.GetValueOrDefault()) { var roleauth = roleauths.FirstOrDefault(d => d.AuthSourceFid == item.Fid && d.AuthType == 4); info.IsAuth = roleauth == null ? false : true; } else { info.IsAuth = true; } info.ParentSourceFid = chartauth.AuthSourceFid.GetValueOrDefault(); list.Add(info); } return(list.OrderBy(d => d.DisplayOrder).ToList()); }