/// <summary> /// 更新快捷键信息,立即回写数据库并发布事件 /// </summary> /// <param name="menuId">菜单部件唯一标示</param> /// <param name="shortcut"></param> public void UpdateShortCut(int menuId, string shortcut) { if (string.IsNullOrEmpty(shortcut)) { if (DicClassic.ContainsKey(menuId)) { DicClassic.Remove(menuId); } } else { if (!DicClassic.ContainsKey(menuId)) { DicClassic.Add(menuId, shortcut); } else { DicClassic[menuId] = shortcut; } } var args = new PublishEventArgs() { EventType = PublishEventType.Core, EventId = EventIdAssign.MenuShourtCutsUpdate, }; args.AddParams(menuId); EventPublish.PublishEvent(args); this.WriteUpdateDbByPrivate(menuId); }
private void WriteUpdateDbByPrivate(int keyId) { SqlLiteHelper.ExecuteNonQuery("delete from menu_classic where id=" + keyId); if (!DicClassic.ContainsKey(keyId)) { return; } string content = ""; foreach (var t in DicClassic[keyId].Items) { content += t; content += "#"; } string strUpdateDirectroy = "insert into menu_classic(id,name,content) values"; strUpdateDirectroy += "(" + keyId + ",'" + DicClassic[keyId].Name + "','" + content + "')"; try { SqlLiteHelper.ExecuteNonQueryInThread(strUpdateDirectroy); } catch (Exception ex) { ex.ToString(); } }
/// <summary> /// 删除快捷键信息,立即回写数据库并发布事件 /// </summary> /// <param name="menuId"></param> public void DeleteShortCut(int menuId) { if (DicClassic.ContainsKey(menuId)) { DicClassic.Remove(menuId); var args = new PublishEventArgs() { EventType = PublishEventType.Core, EventId = EventIdAssign.MenuShourtCutsUpdate, }; args.AddParams(menuId); EventPublish.PublishEvent(args); this.WriteDeleteDbByPrivate(menuId); } }
/// <summary> /// 增加快捷键信息 /// </summary> /// <param name="menuId">菜单部件唯一地址</param> /// <param name="shortcut">名称</param> public void AddShortCut(int menuId, string shortcut) { if (string.IsNullOrEmpty(shortcut)) { return; } if (!DicClassic.ContainsKey(menuId)) { DicClassic.Add(menuId, shortcut); } else { DicClassic[menuId] = shortcut; } }
/// <summary> /// 删除模板菜单,并删除数据库中保留的模板菜单 /// </summary> /// <param name="keyId"></param> public void DeleteMneu(int keyId) { if (DicClassic.ContainsKey(keyId)) { DicClassic.Remove(keyId); WriteDeleteDbByPrivate(keyId); var args = new PublishEventArgs() { EventId = EventIdAssign.ClassicMenuUpdate, EventType = PublishEventType.Core }; args.AddParams(keyId); EventPublish.PublishEvent(args); } }
/// <summary> /// 更新模板菜单 无则增加,并回写数据库 /// </summary> /// <param name="keyId">唯一标示</param> /// <param name="name">模板菜单名称</param> /// <param name="content">模板菜单包含的菜单集合 以#分割开</param> private void UpdateMneu(int keyId, string name, string content) { if (MenuIdControlAssign.MenuClassicIdMin <= keyId && keyId <= MenuIdControlAssign.MenuClassicIdMax) { } else { return; } if (!DicClassic.ContainsKey(keyId)) { DicClassic.Add(keyId, new MenuClassic() { Id = keyId, Name = name }); } DicClassic[keyId].Name = name; string[] sp = content.Split('#'); foreach (var t in sp) { if (string.IsNullOrEmpty(t)) { continue; } try { int x = Convert.ToInt32(t); if (x > 0) { if (!DicClassic[keyId].Items.Contains(x)) { DicClassic[keyId].Items.Add(x); } } } catch (Exception ex) { Wlst.Cr.Core.UtilityFunction.WriteLog.WriteLogError("Error:" + ex); } } }
private void WriteUpdateDbByPrivate(int id) { SqlLiteHelper.ExecuteNonQuery("delete from menu_shortcuts where id=" + id); if (DicClassic.ContainsKey(id)) { var t = DicClassic[id]; if (!string.IsNullOrEmpty(t)) { string strUpdateDirectroy = "insert into menu_shortcuts(id,shortcut) values"; strUpdateDirectroy += "(" + id + ",'" + t + "')"; try { SqlLiteHelper.ExecuteNonQueryInThread(strUpdateDirectroy); } catch (Exception ex) { ex.ToString(); } } } }
/// <summary> /// 更新模板菜单 无则增加,并回写数据库 /// </summary> /// <param name="keyId">唯一标示</param> /// <param name="name">模板菜单名称</param> /// <param name="content">模板菜单包含的菜单集合</param> public void UpdateMneu(int keyId, string name, List <int> content) { if (MenuIdControlAssign.MenuClassicIdMin <= keyId && keyId <= MenuIdControlAssign.MenuClassicIdMax) { } else { return; } if (!DicClassic.ContainsKey(keyId)) { DicClassic.Add(keyId, new MenuClassic() { Id = keyId, Name = name }); } DicClassic[keyId].Name = name; DicClassic[keyId].Items.Clear(); foreach (var t in content) { if (!DicClassic[keyId].Items.Contains(t)) { DicClassic[keyId].Items.Add(t); } } this.WriteUpdateDbByPrivate(keyId); var args = new PublishEventArgs() { EventId = EventIdAssign.ClassicMenuUpdate, EventType = PublishEventType.Core }; args.AddParams(keyId); EventPublish.PublishEvent(args); }