单点登陆 (四)

2014-11-23 23:40:09 · 作者: · 浏览: 50
} } /// /// 获取当前用户有权限菜单ID /// /// public static long[] GetMenuIDes() { if (UserInfo == null) return new long[] { }; return GetMenuIDesBySubAccountID(UserInfo.SubAccountID); } private static IList GetSubAccountMenu(long subAccount) { try { using (WcfTcpClient client = WcfClients.Member.CreateClient()) { IList listMenu = client.Channel.GetStoreMenuBySubAccountID(subAccount); string strCookie = JsonConvert.SerializeObject(listMenu); //HttpContext.Current.Session.Add(MenuSessionName, listMenu); return listMenu; } } catch (Exception ex) { Log.WriteLog(ex); } return new List(); } /// /// 判断子帐号是否具有URL权限 /// /// /// /// public static bool HasMenuOfSubAccount(string url, long subAccount) { //IList listMenu = new List(); //if (HttpContext.Current.Session[MenuSessionName] != null) //{ // listMenu = HttpContext.Current.Session[MenuSessionName] as List; // if (listMenu == null) // { // listMenu = GetSubAccountMenu(subAccount); // } //} //else //{ // listMenu = GetSubAccountMenu(subAccount); //} System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@":\d+", System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex IPreg = new System.Text.RegularExpressions.Regex(@"(\d{1,3}\.){3}\d{1,3}", System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (IPreg.IsMatch(url)) { string hosts = HttpContext.Current.Request.Headers["host"]; if (string.IsNullOrEmpty(hosts)) { hosts = HttpContext.Current.Request.Url.Host; } string pageUrl = HttpContext.Current.Request.Url.PathAndQuery; url = "http://" + hosts + pageUrl; } else if (reg.IsMatch(url)) { url = reg.Replace(url, ""); } IList
listMenu = GetSubAccountMenu(subAccount); if (listMenu.Count > 0) { var instance = CN100.EnterprisePlatform.Configuration.DomainSection.Instance; foreach (var menu in listMenu) { if (!string.IsNullOrEmpty(menu.DomainName)) { if (instance.Urls[menu.DomainName] != null) { string menuUrl = instance.Urls[menu.DomainName].Url + menu.Url; if (menuUrl.ToLower() == url.ToLower()) { return true; } } } } } Log.WriteLog(new Exception("子帐号来访地址:" + url.ToString())); return false; } /// /// /// /// /// public static bool HasMenuOfSubAccount(string url) { if (CurrentUser.IsLogin()) { long subAccountID = CurrentUser.UserInfo.SubAccountID; if (subAccountID > 0) { return HasMenuOfSubAccount(url, subAccountID); } } return false; } /// /// /// /// /// /// public static int GetMessageCountByUserName(string userName, UserType userType) { try { using (WcfTcpClient client = WcfClients.Member.CreateClient()) { return client.Channel.GetUnReadMessageCount(userName, userType); } } catch (Exception ex) { Log.WriteLog(ex); } return 0; } /// /// 获取未读信息 /// /// public static int GetMessageCountByUserName() { if (IsLogin()) { return GetMessageCountByUserName(UserName, GetCurrentUserInfo().UserType); } return 0; } /// /// /// /// /// public static IList GetShopCartQtyByUserID(long UserID) { try { using (WcfTcpClient client = WcfClients.Member.CreateClient