public void EventSub(int id) { EventSubscribe es = new EventSubscribe { StudentId = (int)Session["id"], EventId = id }; eventSubscribeRepository.Insert(es); Response.Redirect(Request.UrlReferrer.ToString()); }
/// <summary> /// 指发送命令 /// </summary> void BatchSendCommand() { if (null == CommandItem || 0 == CommandItem.Count) { this.IsBeginInitControl = false; return; } var cmd = new CtrlPlatformCommandInfo(); cmd.CommandName = ConstantCollection.BATCH_COMMAND; cmd.CommandType = CtrlCommandDirectionType.ClientUI; cmd.FromModel = CtrlCommandDirectionType.ClientUI; cmd.ExecSql = new List <CtrlExecSQLCmd>(); Dictionary <string, XElement> dictCmd = new Dictionary <string, XElement>(); //-->开发处理发命令。 foreach (var item in CommandItem) { foreach (var exec in item.ExecSql) { string methodName = item.TempValue.GetAttributeValue(ConstantCollection.METHOD_NAME); if (dictCmd.ContainsKey(exec.Sql)) { dictCmd[exec.Sql].Add(new XElement("item", new XAttribute(ConstantCollection.COMPOSITE_CONTROL_NAME, item.CompositeControlName), new XAttribute(ConstantCollection.METHOD_NAME, methodName), new XAttribute(ConstantCollection.COMMAND_NAME, item.CommandName), new XAttribute(ConstantCollection.TABLE_NAME, exec.TableName) )); } else { XElement xe = new XElement("sql", new XAttribute("Name", exec.Sql)); xe.Add(new XElement("item", new XAttribute(ConstantCollection.COMPOSITE_CONTROL_NAME, item.CompositeControlName), new XAttribute(ConstantCollection.METHOD_NAME, methodName), new XAttribute(ConstantCollection.COMMAND_NAME, item.CommandName), new XAttribute(ConstantCollection.TABLE_NAME, exec.TableName) )); dictCmd.Add(exec.Sql, xe); } } cmd.ExecSql.AddRange(item.ExecSql); } if (0 == dictCmd.Count) { return; } //cmd.ParamCollection = new XElement("Batch", dictCmd.Values); cmd.TempValue = new XElement("query", new XAttribute(ConstantCollection.METHOD_NAME, "BatchSendCommand")); EventSubscribe.SendCommandMessageMethod(this, new SendCommandMessageEventArgs(CommandItem, cmd)); CommandItem.Clear(); IsBeginInitControl = false; }
/// <summary> /// 发送命令 /// </summary> /// <param name="ctrlCmd"></param> public void SendCommand(CtrlPlatformCommandInfo ctrlCmd) { if (ctrlCmd.CompositeControlName.IsNullOrEmpty()) { AlertMessage("复合控件命令中:复合控件名称参数为空,这样导致复合收到命令"); return; } if (IsBeginInitControl) { CommandItem.Add(ctrlCmd); } else { ctrlCmd.TempValue.Add(new XAttribute(ConstantCollection.COMPOSITE_CONTROL_NAME, ctrlCmd.CompositeControlName)); EventSubscribe.SendCommandMessageMethod(this, new SendCommandMessageEventArgs(ctrlCmd, ctrlCmd)); } }
public void Dispatch(object e) { foreach (object o in handlers) { foreach (MethodInfo mi in o.GetType().GetMethods()) { ParameterInfo[] args = mi.GetParameters(); Type t = e.GetType(); if (args.Length == 1 && (t.IsSubclassOf(args[0].ParameterType) || args[0].ParameterType.Equals(t))) { foreach (Attribute a in EventSubscribe.GetCustomAttributes(mi)) { if (a.GetType() == new EventSubscribe().GetType()) { mi.Invoke(o, new object[] { e }); } } } } } }