protected void Page_Load(object sender, EventArgs e) { Info = AccountImpl.Instance.GetUserInfo(Convert.ToInt32(Request.QueryString["ID"])); AccountInfo cu = ServerImpl.Instance.GetCurrentUser(Context); if (!(cu != null && (cu.IsAdmin || (Info.Type == 0 && cu.ID == Info.ID) || (Info.Type == 1 && cu.ID == Info.Creator)))) { throw new Exception("你没有权限访问该页面!"); } if (cu.IsAdmin && Info.ID != AccountImpl.AdminID) { Depts = AccountImpl.Instance.GetUserDepts(Info.ID); Control depts_ph = FindControl("PlaceHolderDepts"); if (depts_ph != null) depts_ph.Visible = true; } CommandCtrl cmdCtrl = FindControl("CommandCtrl1") as CommandCtrl; cmdCtrl.OnCommand += new CommandCtrl.OnCommandDelegate(cmdCtrl_OnCommand); cmdCtrl.State["Info"] = Info.DetailsJson; Control prepwd_ph = FindControl("PrePasswordPH"); if (prepwd_ph != null) prepwd_ph.Visible = Info.ID == ServerImpl.Instance.GetUserID(Context); Control resetpwd_ph = FindControl("PlaceHolderResetPwd"); if (resetpwd_ph != null) resetpwd_ph.Visible = !Info.IsTemp; }
public Message( AccountInfo sender, AccountInfo receiver, String content, DateTime cteatedTime, int id ) { _senderId = (sender == null ? 0 : sender.ID); _receiverId = (receiver == null ? 0 : receiver.ID); Content = content; CreatedTime = cteatedTime; ID = id; }
private AccountInfo RefreshUserInfo(DataRow userInfo) { if (userInfo != null) { int userId = Convert.ToInt32(userInfo["ID"]); if (cache_.ContainsKey(userId)) { AccountInfo info = cache_[userId] as AccountInfo; info.Reset(userInfo); return info; } else { AccountInfo info = new AccountInfo(userInfo); if (list_.Count >= MAX_CACHE_COUNT) { AccountInfo removeInfo = list_.First.Value; cache_.Remove(removeInfo.ID); list_.RemoveFirst(); } cache_[info.ID] = info; list_.AddLast(info.ListNode); return info; } } else { return null; } }
public Details(AccountInfo info) { _info = info; }
public void LeaveChatRoom(int room_id, AccountInfo user) { lock (m_ChatRoom) { if (!m_ChatRoom.ContainsKey(room_id)) return; if ((m_ChatRoom[room_id] as Hashtable).ContainsKey(user.ID)) (m_ChatRoom[room_id] as Hashtable).Remove(user.ID); } }
public void JoinChatRoom(int room_id, AccountInfo user) { lock (m_ChatRoom) { if (!m_ChatRoom.ContainsKey(room_id)) m_ChatRoom.Add(room_id, new Hashtable()); (m_ChatRoom[room_id] as Hashtable)[user.ID] = user; } }
public Details(AccountInfo info) { this._info = info; }
public Message NewMessage(string receiver, string sender, string content, Hashtable data) { lock (this.m_Lock) { Hashtable config; DateTime time; string str; Hashtable hashtable2; Hashtable hashtable3; long key = this.m_MaxKey += 1L; content = HtmlUtil.ReplaceHtml(content); MsgAccessoryEval eval = new MsgAccessoryEval(key, receiver, sender, data); content = new Regex("{Accessory [^\f\n\r\t\v<>]+}").Replace(content, new MatchEvaluator(eval.Replace)); Message item = new Message(AccountImpl.Instance.GetUserInfo(sender), AccountImpl.Instance.GetUserInfo(receiver), content, new DateTime((DateTime.Now.Ticks / 0x2710L) * 0x2710L), key); new List <Message>().Add(item); if (AccountImpl.Instance.GetUserInfo(receiver).Type == 0L) { if (SessionManagement.Instance.IsOnline(receiver)) { try { config = SessionManagement.Instance.GetAccountState(receiver).GetConfig("message.conf"); lock ((hashtable3 = hashtable2 = config)) { time = (DateTime)config["LastReceivedTime"]; config["LastReceivedTime"] = item.CreatedTime; } str = Utility.RenderHashJson(new object[] { "Peer", sender, "Message", item }); SessionManagement.Instance.Send(receiver, "GLOBAL:IM_MESSAGE_NOTIFY", str); } catch { } } } else { AccountInfo userInfo = AccountImpl.Instance.GetUserInfo(receiver); AccountInfo info2 = AccountImpl.Instance.GetUserInfo(sender); foreach (string str2 in userInfo.Friends) { try { AccountInfo info3 = AccountImpl.Instance.GetUserInfo(str2); if (((info2.Name.ToLower() == "administrator") || (info3.ID != info2.ID)) && SessionManagement.Instance.IsOnline(str2)) { config = SessionManagement.Instance.GetAccountState(info3.Name).GetConfig("message.conf"); lock ((hashtable3 = hashtable2 = config)) { time = (DateTime)config["LastReceivedTime"]; config["LastReceivedTime"] = item.CreatedTime; } str = Utility.RenderHashJson(new object[] { "Peer", userInfo.Name, "Message", item }); SessionManagement.Instance.Send(str2, "GLOBAL:IM_MESSAGE_NOTIFY", str); } } catch { } } } MessageCacheManagement.Instance.Insert(receiver, item); if (MessageCacheManagement.Instance.Count >= 4) { this.WriteCache(); } return(item); } }
public List <Message> Find(string user, string sender, DateTime from) { int num; Hashtable hashtable; List <Message> list; Hashtable hashtable2; List <Message> list6; List <Message> list2 = new List <Message>(); List <Message> userMessageCache = null; lock ((hashtable2 = hashtable = this.m_Cache)) { userMessageCache = this.GetUserMessageCache(user); } lock ((list6 = list = userMessageCache)) { num = 0; while ((num < userMessageCache.Count) && (userMessageCache[num].CreatedTime <= from)) { num++; } while (num < userMessageCache.Count) { if (((sender == null) || (sender == "*")) || (sender == userMessageCache[num].Sender.Name)) { list2.Add(userMessageCache[num]); } num++; } } if ((sender == null) || (sender == "*")) { AccountInfo userInfo = AccountImpl.Instance.GetUserInfo(user); foreach (string str in userInfo.Groups) { AccountInfo info2 = AccountImpl.Instance.GetUserInfo(str); List <Message> list4 = null; lock ((hashtable2 = hashtable = this.m_Cache)) { list4 = this.GetUserMessageCache(str); } lock ((list6 = list = list4)) { if (from < info2.GetGroupMemberRenewTime(user)) { from = info2.GetGroupMemberRenewTime(user); } num = 0; while ((num < list4.Count) && (list4[num].CreatedTime <= from)) { num++; } while (num < list4.Count) { list2.Add(list4[num]); num++; } } } } return(list2); }
public void CheckPermission(HttpContext context, string path, int action) { string relative = Path.GetRelativePath(path); string relativeRoot = Path.GetRoot(relative).ToLower(); bool isRootItem = String.Compare(relative, relativeRoot, true) == 0; if ((relativeRoot == "pub") && !isRootItem && action == IOPermission.Read) { return; } if ((relativeRoot == "public") && !isRootItem && action == IOPermission.Read) { return; } AccountInfo currentUser = ServerImpl.Instance.GetCurrentUser(context); if (currentUser != null && currentUser.ID == 3) { return; } int owner = Path.GetUser(path); if (owner == 0) { owner = currentUser.ID; } AccountInfo ownerInfo = AccountImpl.Instance.GetUserInfo(owner); if (ownerInfo.Type == 1 && (ownerInfo.ContainsMember(currentUser.ID) || ownerInfo.SubType == 3)) { return; } if (relativeRoot == "message" && ownerInfo.Type == 1) { try { string[] nodes = relative.Split(new char[] { '/' }, 3, StringSplitOptions.RemoveEmptyEntries); if (nodes.Length >= 2) { int msg_id = Convert.ToInt32(nodes[1].Substring(3)); if (!MessageImpl.Instance.CheckPermission(currentUser.ID, msg_id)) { throw new PermissionException(); } if (action == IOPermission.Read) { return; } } } catch { } } if (currentUser == null || ownerInfo.ID != currentUser.ID) { throw new PermissionException(); } if (String.IsNullOrEmpty(relative) && (RootDirectoryPermission & action) != action) { throw new PermissionException(); } if (String.Compare(relative, relativeRoot, true) == 0) { if (relativeRoot == "public") { if ((RootPublicSubItemsPermission & action) != action) { throw new PermissionException(); } } else { if ((RootSubItemsPermission & action) != action) { throw new PermissionException(); } } } else { if (relativeRoot == "public") { if ((PublicSubItemsPermission & action) != action) { throw new PermissionException(); } } else { } } }