/// <summary> /// 注册会话 /// </summary> /// <param name="sessionId">会话标识</param> /// <param name="user">用户名</param> /// <param name="ipAddress">调用方IP地址</param> /// <param name="encryptKey">密钥</param> public void Register(string sessionId, string user, string ipAddress, string encryptKey) { lock (syncObj) { if (sessions.ContainsKey(sessionId)) { throw new ArgumentException(String.Format("会话管理器中已经存在 [{0}] 的会话", sessionId)); } logger.Info(String.Format("注册来自 {0} [{1}] 的会话 : [{2}]", user, ipAddress, sessionId)); SessionState session = new SessionState(sessionId, timeOut); session[SessionVariables.SESSION_ID] = sessionId; session[SessionVariables.SESSION_CURRENT_USER] = user; session[SessionVariables.SESSION_CLIENT_ADDRESS] = ipAddress; session[SessionVariables.SESSION_ENCRYPTKEY] = encryptKey; session[SessionVariables.SESSION_LOGIN_TIME] = DateTime.Now; // 会话状态上下文变化事件 session.ContextChanged += new EventHandler(delegate(object sender, EventArgs e) { string id = ((SessionState)sender).SessionId; IList <SessionState> list = db.Load <SessionState>(delegate(SessionState ss) { return(ss.SessionId == id); }); if (list.Count > 0) { db.Delete(list[0]); // 删除原来的会话状态数据 } db.Store(sender); }); // 将新注册的会话资料保存到数据库 db.Store(session); sessions[sessionId] = session; } }
/// <summary> /// 删除操作命令 /// </summary> /// <param name="command">命令</param> public void Delete(AuthorizationCommand command) { IList <AuthorizationCommand> lcs = db.Query <AuthorizationCommand>((AuthorizationCommand cmd) => cmd.Name == command.Name && cmd.CommandUri == cmd.CommandUri); foreach (AuthorizationCommand cmd in lcs) { db.Delete(cmd); // 删除所有的操作 } }
/// <summary> /// 删除一个软件更新项目 /// </summary> /// <param name="product">项目名称</param> /// <param name="version">软件版本</param> public void DeleteUpgradeProject(string product, string version) { UpgradeProject project = GetUpgradeProject(product, version); if (project != null) { db.Delete(project); } }
/// <summary> /// 删除授权节点 /// </summary> /// <param name="node">授权节点</param> public void Delete(AuthorizationNode node) { IList <AuthorizationNode> lns = db.Query <AuthorizationNode>((AuthorizationNode an) => an.AuthorizationUri == node.AuthorizationUri); foreach (AuthorizationNode an in lns) { db.Delete(an); // 删除所有授权节点 } }
/// <summary> /// Deletes the specified property. /// </summary> /// <param name="property">The property.</param> public void Delete(string property) { IList <Property> objs = db.Load <Property>(delegate(Property prop) { return(prop.Name == property); }); foreach (Property obj in objs) { db.Delete(obj); } }
private void ReregisterOuterEvent() { List <OuterEventInfo> eventList = new List <OuterEventInfo>(db.Load <OuterEventInfo>()); eventList.ForEach(delegate(OuterEventInfo info) { try { RegisterOuterEventSubscriber(info.SessionId, info.Topic, info.Location); } catch { db.Delete(info); } }); }
public void Remove(Request request) { IList <Request> results = dbService.Load <Request>(delegate(Request queryRequest) { return(request.RequestId == queryRequest.RequestId); }); if (results.Count > 0) { dbService.Delete(results[0]); if (RequestQueueChanged != null) { RequestQueueChanged(this, new RequestQueueEventArgs(results[0], GetCount())); } } }
private void DeleteLayout(string user, string appUri) { IList <Layout> layouts = db.Query <Layout>(lay => lay.User == user && lay.AppUri == appUri); if (layouts.Count > 0) { db.Delete(layouts[0]); } }
/// <summary> /// 从后台存储中删除指定角色的授权信息 /// </summary> /// <param name="role">The role.</param> public void DeleteAuthorization(string role) { IList <AuthorizationStore> results = db.Load <AuthorizationStore>(delegate(AuthorizationStore authStore) { return(authStore.Role == role); }); // 从数据库中删除角色的授权信息 if (results.Count > 0) { db.Delete(results[0]); } }