/// <summary> /// Sends the action package of the player, indicating the inputs that the player /// has done in the past few milliseconds. /// </summary> public void SendPlayerActionPackage(IEnumerable <PlayerAction> actions) { SendCommand(ClientCommand.ActionPackage, (msg) => { foreach (PlayerAction action in actions) { ulong id = action.ID; float time = action.Time; byte type = (byte)action.Type; float x = action.Position.X; float y = action.Position.Y; msg.Write(id); msg.Write(time); msg.Write(type); msg.Write(x); msg.Write(y); if (ActionTypeHelper.IsSpell(action.Type)) { Debug.Assert(action.Target != null, "Trying to us target on non-spell action."); float tx = action.Target.X; float ty = action.Target.Y; msg.Write(tx); msg.Write(ty); } } }); }
/// <summary> /// 列表事件 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { String ID = ((CheckBox)e.Item.FindControl("ID")).Text; Int32 GroupID = Convert.ToInt32(((HiddenField)e.Item.FindControl("Groupid")).Value); T_AccessControlEntity acl = Access.Find(a => { return(a.Node == GroupID); }); if (ActionTypeHelper.IsDelete(acl.ActionType) || ActionTypeHelper.IsSetting(acl.ActionType)) { switch (e.CommandName) { case "del": DELContentImages(ID); db.ExecuteCommand(String.Format("DELETE FROM [t_news] WHERE id in ({0})", ID)); break; case "focus": case "stick": case "status": ExecuteObject obj = new ExecuteObject(); obj.cmdtype = CmdType.UPDATE; obj.tableName = "t_news"; obj.terms.Add("id", ID); obj.cells.Add(e.CommandName, !Convert.ToBoolean(e.CommandArgument)); db.ExecuteCommand(obj); break; } BindData(); } }
public Group UpdateUserGroup(PartyId partyId, string description, Dictionary <int, bool> customActions) { try { using (var scope = new TransactionScope()) { var ug = userRep.GetUserGroupById(partyId); //var validSelectedActions = // ActionType.GetAll<ActionType>() // .Where(c => customActions.Keys.Contains(int.Parse(c.Value))) // .ToList(); //var validCustomActions = validSelectedActions.ToDictionary(c => c, // c => customActions[int.Parse(c.Value)]); var validSelectedActions = ActionTypeHelper.SelectActionTypes(customActions.Keys); var validCustomActions = validSelectedActions.ToDictionary(c => c, c => customActions[(int)c]); ug.Update(description, validCustomActions); scope.Complete(); return(ug); } } catch (Exception exp) { var res = userRep.TryConvertException(exp); if (res == null) { throw; } throw res; } }
/// <summary> /// 绑定数据 /// </summary> private void BindData() { @Template.DataSource = Enum.GetValues(typeof(SiteTemplate)); @Template.DataBind(); @TableName.Text = tableName; //权限资源 actiontype.DataSource = ActionTypeHelper.ActionList(); actiontype.DataTextField = "value"; actiontype.DataValueField = "key"; actiontype.DataBind(); actiontype.SelectedIndex = 0; //绑定字段数据 var table = SiteTable.Tables.Find(a => { return(a.TableName == tableName); }); foreach (var item in table.Columns) { String _name = String.IsNullOrEmpty(item.Description) ? item.FieldName : item.Description; @Field.Items.Add(new ListItem(_name, item.FieldName)); } //绑定树形分类 foreach (var item in TreeNodes) { ListItem node = new ListItem(item.GroupName, item.ID.ToString()); node.Attributes.Add("pid", item.ParentID.ToString()); ParentID.Items.Add(node); } var root = new ListItem("顶级分类", "0"); root.Selected = true; ParentID.Items.Insert(0, root); }
/// <summary> /// 绑定数据 /// </summary> protected void BindData() { ActionTypeNames = ActionTypeHelper.ActionList(); ActionTypeValues = Enum.GetValues(typeof(ActionType)); //角色已分配权限 String strSql = "SELECT * FROM [T_AccessControl] WHERE role=" + EditID; ActionTypeList = db.ExecuteObject <List <T_AccessControlEntity> >(strSql); //功能权限 strSql = "SELECT id,parentid,layer,title,actiontype,link_url FROM [T_SiteMenu] ORDER BY sortid"; DataTable dt = db.ExecuteDataTable(strSql); DataTable ds = dt.Clone(); dt.SortTable(ds, 0); Repeater1.DataSource = ds; Repeater1.DataBind(); //新闻权限 strSql = "SELECT id,parentid,layer,groupname,actiontype FROM [T_Group] WHERE tablename='t_news' ORDER BY id"; dt = db.ExecuteDataTable(strSql); ds = dt.Clone(); dt.SortTable(ds, 0); Repeater2.DataSource = ds; Repeater2.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region 权限读取 List <Int32> nodes = new List <Int32>(); var list = new List <T_AccessControlEntity>(); if (IsEdit) { list = Access.FindAll(a => { return(Admin.IsSuper | ActionTypeHelper.IsCreat(a.ActionType) | ActionTypeHelper.IsEdit(a.ActionType)); }); } else { list = Access.FindAll(a => { return(Admin.IsSuper | ActionTypeHelper.IsCreat(a.ActionType)); }); } foreach (var item in list) { nodes.Add(item.Node); } #endregion #region 绑定分类数据 ListItem root = new ListItem("选择分类", "0"); root.Selected = true; GroupId.Items.Add(root); List <T_GroupEntity> treenodes = T_GroupHelper.Groups.FindAll(a => { return(a.TableName == "t_news" & (Admin.IsSuper || nodes.Contains(a.ID))); }); foreach (var item in treenodes) { ListItem el = new ListItem(item.GroupName, item.ID.ToString()); el.Attributes.Add("pid", item.ParentID.ToString()); GroupId.Items.Add(el); } #endregion if (IsEdit) { LoadData(); } else { //通过IE右键收藏网页数据 if (Request["by"] == "ie") { @title.Text = HttpUtility.UrlDecode(Request["title"]); @content.Text = HttpUtility.UrlDecode(Request["content"]); @Url.Value = HttpUtility.UrlDecode(Request["url"]); } } } }
/// <summary> /// 功能权限绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView dv = e.Item.DataItem as DataRowView; Int32 id = Convert.ToInt32(dv["id"]); T_AccessControlEntity acl = data.Find(a => { return(a.Node == id && a.TableName == "t_sitemenu"); }); if (acl != null) { ((CheckBox)e.Item.FindControl("CheckBox1")).Checked = ActionTypeHelper.IsView(acl.ActionType); } } }
/// <summary> /// Package local input as actions to eventually send to the server. /// At the same time, we simulate the input locally for client-side prediction. /// </summary> void HandleInput() { if (OurChampion != null && OurChampion.Champion.Alive && !WinLoseScreen.Visible) { InputTypeForAction.ForEach(pair => { if (inputManager.IsActionFired(pair.Key)) { OurChampion.PackageAction(pair.Value, ActionTypeHelper.IsSpell(pair.Value) ? GetTargetWorldPosition() : null); } }); } }
/// <summary> /// 加载编辑数据 /// </summary> protected void LoadData() { String sql = String.Format("SELECT a.*,b.groupname FROM [T_News] as a LEFT JOIN [T_Group] as b ON a.groupid = b.ID WHERE a.ID={0}", EditID); T_NewsEntity data = db.ExecuteObject <T_NewsEntity>(sql); ViewState["data"] = data; this.SetFormValue(data); T_AccessControlEntity acl = Access.Find(a => { return(a.Node == data.GroupId); }); if (!Admin.IsSuper && !ActionTypeHelper.IsSetting(acl.ActionType)) { nominate.Enabled = hotspot.Enabled = focus.Enabled = stick.Enabled = status.Enabled = false; } }
/// <summary> /// 批量删除 批量启用 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { List <Int32> list = new List <Int32>() { 0 }; Int32 arg = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]); if (arg == 0 || arg == 1 || arg == -1) { foreach (RepeaterItem item in Repeater1.Items) { CheckBox chkbox = item.FindControl("id") as CheckBox; HiddenField groupid = item.FindControl("Groupid") as HiddenField; if (chkbox.Checked) { T_AccessControlEntity acl = Access.Find(a => { return(a.Node == Convert.ToInt32(groupid.Value)); }); if (Admin.IsSuper || (ActionTypeHelper.IsSetting(acl.ActionType) || ActionTypeHelper.IsDelete(acl.ActionType))) { list.Add(Convert.ToInt32(chkbox.Text)); } } } String id = String.Join(",", list.ToArray()); switch (arg) { case 0: //禁用 db.ExecuteCommand(String.Format("UPDATE [t_news] SET status = 0 WHERE id IN({0})", id)); break; case -1: //删除 foreach (var _id in list) { DELContentImages(_id); } db.ExecuteCommand(String.Format("DELETE FROM [t_news] WHERE id in ({0})", id)); break; case 1: //启用 db.ExecuteCommand(String.Format("UPDATE [t_news] SET status = 1 WHERE id IN({0})", id)); break; } BindData(); } }
void HandleAction(ServerClient client, PlayerAction action) { if (ActionTypeHelper.IsSpell(action.Type)) { var spell = ChampionTypesHelper.GetSpellFromAction(client.Champion.Type, action.Type); if (client.ChampStats.Alive && !client.ChampStats.IsOnCooldown(spell)) // we're not dead and the spell is not on cooldown { CastChampionSpell(client.Champion, action); client.ChampStats.UsedSpell(spell); } } else if (action.Type != PlayerActionType.Idle) { ILogger.Log("Unknown player action type: " + action.Type); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { T_NewsEntity data = (T_NewsEntity)ViewState["data"]; data = this.GetFormValue <T_NewsEntity>(data); CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT; data.EditDate = DateTime.Now; if (!IsEdit) { data.PubDate = DateTime.Now; } T_AccessControlEntity acl = Access.Find(a => { return(a.Node == data.GroupId); }); if (ActionTypeHelper.IsCreat(acl.ActionType) || (IsEdit && ActionTypeHelper.IsEdit(acl.ActionType))) { #region 网络图片采集 HtmlDocument xml = new HtmlDocument(); xml.LoadHtml(data.Content); var html = xml.DocumentNode; var nodes = html.CssSelect("img[src^='http:']"); foreach (HtmlNode n in nodes) { HtmlAttribute src = n.Attributes["src"]; src.Value = DownloadImage(src.Value); } data.Content = xml.DocumentNode.WriteTo(); content.Text = data.Content; #endregion if (db.ExecuteCommand <T_NewsEntity>(data, cmd)) { if (!IsEdit) { this.ClearFromValue(); } Alert(Label1, "保存成功!", "line1px_3"); } } }
/// <summary> /// 更新权限设置 /// </summary> /// <param name="nodeId">权限节点</param> protected void UpdateAccessControl(T_GroupEntity data) { String sql = "SELECT * FROM [T_AccessControl] WHERE tablename='t_group' AND node=" + data.ID; List <T_AccessControlEntity> acc = db.ExecuteObject <List <T_AccessControlEntity> >(sql); foreach (T_AccessControlEntity node in acc) { List <ActionType> items = ActionTypeHelper.GetValueItem(node.ActionType); foreach (ActionType n in items) { if (!data.ActionType.HasFlag(n)) { node.ActionType = ActionTypeHelper.RemoveACLoptions(node.ActionType, n); } } } db.ExecuteCommand <List <T_AccessControlEntity> >(acc, CmdType.UPDATE); }
void OnActionPackage(NetIncomingMessage message) { Debug.Assert(Clients.ContainsKey(message.SenderConnection)); try { while (message.Position < message.LengthBits) { ulong id = message.ReadUInt64(); float time = message.ReadFloat(); PlayerActionType type = (PlayerActionType)message.ReadByte(); Vec2 position = new Vec2(message.ReadFloat(), message.ReadFloat()); Vec2 target = ActionTypeHelper.IsSpell(type) ? new Vec2(message.ReadFloat(), message.ReadFloat()) : null; PlayerAction action = new PlayerAction(id, type, time, position, target); Clients[message.SenderConnection].ActionsPackage.Add(action); } } catch (Exception e) { ILogger.Log("Action package badly formatted: " + e.ToString(), LogPriority.Error); } }
/// <summary> /// 更新权限设置 /// </summary> /// <param name="nodeId">权限节点</param> protected void UpdateAccessControl(T_SiteMenuEntity data) { String strSql = "SELECT * FROM [T_AccessControl] WHERE tablename='t_sitemenu' AND node=" + data.ID; List <T_AccessControlEntity> acc = db.ExecuteObject <List <T_AccessControlEntity> >(strSql); foreach (T_AccessControlEntity node in acc) { List <ActionType> items = ActionTypeHelper.GetValueItem(node.ActionType); foreach (ActionType n in items) { if (!data.ActionType.HasFlag(n)) { node.ActionType = ActionTypeHelper.RemoveACLoptions(node.ActionType, n); } } } db.ExecuteCommand <List <T_AccessControlEntity> >(acc, CmdType.UPDATE); CacheHelper.Delete(ISessionKeys.cache_table_accesscontrol); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String strSql = String.Format("SELECT id,title FROM [T_SiteMenu] WHERE ParentID=0 AND id<>{0} ORDER BY id", EditID); parentid.DataSource = db.ExecuteDataTable(strSql); parentid.DataTextField = "title"; parentid.DataValueField = "id"; parentid.DataBind(); parentid.Items.Insert(0, new ListItem("顶级分类", "0")); actiontype.DataSource = ActionTypeHelper.ActionList(); actiontype.DataTextField = "value"; actiontype.DataValueField = "key"; actiontype.DataBind(); if (IsEdit) { LoadData(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindField(dropField, "t_news", "title"); #region 权限读取 List <Int32> nodes = new List <Int32>() { 0 }; foreach (var item in Access.FindAll(a => { return(Admin.IsSuper | ActionTypeHelper.IsView(a.ActionType)); })) { nodes.Add(item.Node); } PowerNodes = nodes; #endregion #region 绑定分类数据 ListItem element = new ListItem("选择分类", "0"); element.Selected = true; dropGroup.Items.Add(element); List <T_GroupEntity> treenodes = T_GroupHelper.Groups.FindAll(a => { return(a.TableName == "t_news" && (Admin.IsSuper || nodes.Contains(a.ID))); }); foreach (var item in treenodes) { ListItem el = new ListItem(item.GroupName, item.ID.ToString()); el.Attributes.Add("pid", item.ParentID.ToString()); dropGroup.Items.Add(el); } #endregion BindData(); } }
/// <summary> /// 控件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataRowView dv = e.Item.DataItem as DataRowView; Int32 ID = Convert.ToInt32(dv["id"]); Int32 GroupID = Convert.ToInt32(dv["GroupID"]); CheckBox chk = e.Item.FindControl("id") as CheckBox; ImageButton del = e.Item.FindControl("del") as ImageButton; ImageButton edit = e.Item.FindControl("edit") as ImageButton; ImageButton status = e.Item.FindControl("status") as ImageButton; ImageButton focus = e.Item.FindControl("focus") as ImageButton; ImageButton stick = e.Item.FindControl("stick") as ImageButton; if (Convert.ToBoolean(dv["status"])) { status.ImageUrl = "images/icos/checkbox_yes.png"; } if (Convert.ToBoolean(dv["focus"])) { focus.ImageUrl = "images/icos/checkbox_yes.png"; } if (Convert.ToBoolean(dv["stick"])) { stick.ImageUrl = "images/icos/checkbox_yes.png"; } edit.OnClientClick = String.Format("javascript:location.href='News_Edit.aspx?id={0}';return false;", ID); del.OnClientClick = String.Format("javascript:dialogConfirm({{el:this,text:'将删除 {0} 且无法恢复!确定要删除吗?'}});return false;", dv["title"]); if (!Admin.IsSuper) { T_AccessControlEntity acl = Access.Find(a => { return(a.Node == GroupID); }); if (!ActionTypeHelper.IsEdit(acl.ActionType)) { edit.Enabled = false; edit.ToolTip = "无权限修改."; edit.ImageUrl = "images/icos/write_disable.gif"; } if (!ActionTypeHelper.IsDelete(acl.ActionType)) { del.Enabled = false; del.ToolTip = "无权限删除."; del.ImageUrl = "images/icos/del_disabled.gif"; } if (!ActionTypeHelper.IsSetting(acl.ActionType)) { stick.Enabled = focus.Enabled = status.Enabled = false; stick.ToolTip = focus.ToolTip = status.ToolTip = "无权限设置."; if (Convert.ToBoolean(dv["status"])) { status.ImageUrl = "images/icos/checkbox_disabled.png"; } if (Convert.ToBoolean(dv["focus"])) { focus.ImageUrl = "images/icos/checkbox_disabled.png"; } if (Convert.ToBoolean(dv["stick"])) { stick.ImageUrl = "images/icos/checkbox_disabled.png"; } } } } }