using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Configuration; using System.Xml; using ICSharpCode.Core; using System.Windows.Forms; namespace Mesnac.Gui.Common { public delegate void ExecutionAction(); /// /// 事件绑定处理类 /// public class MCEventHandler { private Component _currentControl; private List _MCActionList; public MCEventHandler() { } public MCEventHandler(Component c, object actionList) { this._currentControl = c; this._MCActionList = actionList as List; } public Component CurrentControl { get { return _currentControl; } set { _currentControl = value; } } public List MCActionList { get { return _MCActionList; } set { _MCActionList = value; } } public void ExecuteAction(object sender, System.EventArgs e, string eventId) { try { string t = sender.GetType().Name; //if (sender.GetType() == typeof(Mesnac.Controls.Default.MCButton)) //{ // if ((sender as Mesnac.Controls.Default.MCButton).MCPurview) // { // Mesnac.Controls.Base.DesignAction designAction = new Mesnac.Controls.Base.DesignAction(); // designAction.GUID = "941988F1F078444996F53518FAE63C31"; // designAction.Name = "通用权限验证"; // designAction.Remark = "系统登录与权限验证"; // (sender as FrmRunTemplate).LoadActionList.Add(designAction); // } //} //窗体加载时的权限处理 if (sender.GetType() == typeof(FrmRunTemplate)) { if ((sender as FrmRunTemplate).MCPurview) { Mesnac.Controls.Base.DesignAction designAction = new Mesnac.Controls.Base.DesignAction(); designAction.GUID = "EE88F12802884A19B5D9BE2310E2B605"; designAction.Name = "通用权限控制"; designAction.Remark = "根据权限处理界面控件"; (sender as FrmRunTemplate).LoadActionList.Add(designAction); } } if (sender.GetType() == typeof(Mesnac.Controls.Default.MCButton)) { if ((sender as Mesnac.Controls.Default.MCButton).MCPurview) { FrmSysLogin login = new FrmSysLogin(((sender as Mesnac.Controls.Default.Button).FindForm()) as FrmRunTemplate, sender as Mesnac.Controls.Default.MCButton); if (login.ShowDialog() != DialogResult.OK) return; login.Close(); } } //添加单选按钮权限 //if (sender.GetType() == typeof(Mesnac.Controls.Default.MCRadioButton)) //{ // if ((sender as Mesnac.Controls.Default.MCRadioButton).MCPurview) // { // FrmSysLogin login = new FrmSysLogin(((sender as Mesnac.Controls.Default.MCRadioButton).FindForm()) as FrmRunTemplate, sender as Mesnac.Controls.Default.MCButton); // if (login.ShowDialog() != DialogResult.OK) // return; // login.Close(); // } //} //LoggingService.Info("当前sender" + t); XmlNode tmpXEventNode = PublicConfig.Instance.EventXmlDoc.SelectSingleNode(String.Format("Components/Component[@Name=\"{0}\"]", t)); if (tmpXEventNode != null) { XmlNodeList tmpXActionLst = tmpXEventNode.SelectNodes("Propertys/Property"); foreach (XmlNode node in tmpXActionLst) { System.Reflection.PropertyInfo propertyInfo = sender.GetType().GetProperty(node.Attributes["Name"].Value); //获取事件名称属性 if (propertyInfo == null) { continue; } string eventName = node.Attributes["ControlPropertyName"].Value; if (eventName != null && eventName.Equals(eventId)) { object actionList = propertyInfo.GetValue(sender, null); this._MCActionList = actionList as List; List actions = new List(); if (this._MCActionList != null) { foreach (Mesnac.Controls.Base.DesignAction action in this._MCActionList) { actions.Add(action.GUID); //LoggingService.Debug(String.Format("执行{0}-{1}-{2}", action.GUID, action.Name, action.Remark)); } } Mesnac.ActionService.Service.Instance.Run((Mesnac.Controls.Base.IBaseControl)sender, e, actions); } } } } catch (Exception ex) { LoggingService.Debug(ex.Message); LoggingService.Debug(ex.StackTrace); } } } }