private void UpdateView(IMenu menu) { if (menu.Key == null) { return; } ApplicationService.Current().MainWindows.ultraExplorerBar.Groups.Clear(); Infragistics.Win.UltraWinExplorerBar.UltraExplorerBarGroup barGroup = ApplicationService.Current().MainWindows.ultraExplorerBar.Groups.Add( menu.Key.ToString().Trim(), menu.Caption.ToString().Trim()); //barGroup.ItemSettings. for (int i = 0; i < menu.SubMenus.Length; i++) { if (menu.SubMenus[i].Key != null) { barGroup.Items.Add(menu.SubMenus[i].Key.ToString().Trim(), menu.SubMenus[i].Caption.ToString().Trim()); } } }
private void DispathSubToolbarOnClick(object key, IMenu menu) { try { for (int i = 0; i < menu.SubMenus.Length; i++) { if (menu.SubMenus[i].Key != null) { if (menu.SubMenus[i].Key.Equals(key)) { // 检查权限 bool needCheck = true; foreach (string needlessCheckKey in this.getNeedlessCheckRightKey()) { if (key.ToString() == needlessCheckKey) { needCheck = false; break; } } if (needCheck) { if (ApplicationService.Current().UserCode == null) { ApplicationRun.GetInfoForm().Add("请先登录系统!"); return; } // 检查Resource权限 //Laws Lu,2005/08/31,修改 Admin组权限,允许Pass // ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.OpenConnection(); //2005/10/26,修改 缓解性能 object[] objUserGroup = ApplicationService.Current().LoginInfo.UserGroups; //(new BaseSetting.UserFacade(_domainDataProvider)).GetUserGroupofUser(ApplicationService.Current().UserCode); bool bIsAdmin = false; if (objUserGroup != null) { foreach (object o in objUserGroup) { if (((BenQGuru.eMES.Domain.BaseSetting.UserGroup)o).UserGroupType == "ADMIN") { bIsAdmin = true; break; } } } if (!bIsAdmin) { // if ( !this._facade.CheckResourceRight(ApplicationService.Current().UserCode, ApplicationService.Current().ResourceCode) ) // { // throw new Exception("$Error_No_Resource_Right"); // return; // } if (!this._facade.CheckAccessRight(ApplicationService.Current().UserCode, key.ToString().ToUpper())) { //throw new Exception("没有访问权限!"); ApplicationRun.GetInfoForm().Add(new UserControl.Message(UserControl.MessageType.Error, "$Error_No_Access_Right")); return; } } // if ( ApplicationService.Current().UserCode != "ADMIN" && !this._facade.CheckAccessRight(ApplicationService.Current().UserCode, key.ToString()) ) // { // ApplicationRun.GetInfoForm().Add("没有访问权限!"); // return; // } } if (menu.SubMenus[i].Command != null) { menu.SubMenus[i].Command.Execute(); } break; } if (menu.SubMenus[i].SubMenus != null) { DispathSubToolbarOnClick(key, menu.SubMenus[i]); } } } } catch { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.CloseConnection(); } finally { ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.CloseConnection(); } }
public IMenu[] Build() { this.GetUnVisibilityMenu(ApplicationService.Current().DataProvider); SystemSettingFacade facade = new SystemSettingFacade(ApplicationService.Current().DataProvider); bool bIsAdmin = false; string strUserCode = ApplicationService.Current().UserCode; if (strUserCode.ToUpper() == "ADMIN") { bIsAdmin = true; } else { for (int i = 0; ApplicationService.Current().LoginInfo.UserGroups != null && i < ApplicationService.Current().LoginInfo.UserGroups.Length; i++) { if (((UserGroup)ApplicationService.Current().LoginInfo.UserGroups[i]).UserGroupType == "ADMIN") { bIsAdmin = true; break; } } } if (bIsAdmin == true) { strUserCode = string.Empty; } ITreeObjectNode rootNode = facade.BuildMenuTreeCS(strUserCode); TreeObjectNodeSet set = rootNode.GetSubLevelChildrenNodes(); ArrayList listMenu = new ArrayList(); foreach (MenuTreeNode node in set) { if (node.MenuWithUrl.MenuType.ToUpper() == MenuType.MenuType_CS.ToUpper()) { if (this.menuHT != null && this.menuHT.Contains(node.MenuWithUrl.ModuleCode)) { continue; } if (this.htUnVisibilityMenu != null && this.htUnVisibilityMenu.Contains(node.MenuWithUrl.MenuCode)) { continue; } listMenu.Add(BuildUltraMenuItem(node)); } } if (listMenu.Count > 0) { MenuCommand[] menuList = new MenuCommand[listMenu.Count]; listMenu.CopyTo(menuList); return(menuList); } return(null); }
//added by carey.cheng on 2010-05-20 for muti db support public static ApplicationService Login(string ConnectDB) { _dataProvider = BenQGuru.eMES.Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider(ConnectDB); _applicationService = new ApplicationService(_dataProvider); return(_applicationService); }
public void GetXMLMenu() { try { if (menuHT != null) { return; } menuHT = new Hashtable(); string strFile = System.Windows.Forms.Application.StartupPath + "\\MenuRight.xml"; if (System.IO.File.Exists(strFile) == false) { return; } System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(strFile); #region 加载版本限制Menu (将不会显示) System.Xml.XmlNode node = doc.SelectSingleNode(string.Format("//MenuRightVersion")); if (node != null) { System.Xml.XmlNodeList selectNodes = node.SelectNodes("ModuleCode"); if (selectNodes != null && selectNodes.Count > 0) { foreach (System.Xml.XmlNode _childnode in selectNodes) { string disply = _childnode.Attributes["Disply"].Value.Trim().ToUpper(); if (disply == "FALSE") { string code = _childnode.Attributes["Code"].Value; if (!menuHT.Contains(code)) { menuHT.Add(code, code); } } } } } node = null; #endregion #region 加载限制Menu (只有Admin才可以访问,其它用户不会显示) if (ApplicationService.Current().UserCode != null && ApplicationService.Current().UserCode.ToUpper() != "ADMIN") { System.Xml.XmlNode node2 = doc.SelectSingleNode(string.Format("//MenuRightAdmin")); if (node2 != null) { System.Xml.XmlNodeList selectNodes = node2.SelectNodes("ModuleCode"); if (selectNodes != null && selectNodes.Count > 0) { foreach (System.Xml.XmlNode _childnode in selectNodes) { string disply = _childnode.Attributes["Disply"].Value.Trim().ToUpper(); if (disply == "FALSE") { string code = _childnode.Attributes["Code"].Value; if (!menuHT.Contains(code)) { menuHT.Add(code, code); } } } } } node2 = null; } #endregion doc = null; } catch {} }