internal User FromUser(User user) { lock (UserCacheLocker) { if (!UserCache.ContainsKey(user)) { UserCache.Add(user, false); } return(user); } }
internal ApiUser ApiUser(User user) { lock (UserCacheLocker) { if (UserCache.ContainsKey(user)) { return(UserCache[user]); } UserCache.Add(user, null); return(null); } }
public ApiUser ApiUser(User user) { lock (UserCacheLocker) { if (UserCache.ContainsKey(user)) { return UserCache[user]; } UserCache.Add(user,null); return null; } }
internal void SetUserSubbed(User user, bool subbed) { lock (UserCacheLocker) { if (UserCache.ContainsKey(user)) { UserCache[user] = subbed; return; } UserCache.Add(user, subbed); } }
internal bool IsUserSubbed(User user) { lock (UserCacheLocker) { if (UserCache.ContainsKey(user)) { return(UserCache[user]); } UserCache.Add(user, false); return(false); } }
private void mnuEditAdd_Click(object sender, EventArgs e) { User u = new User() { UserId = Guid.NewGuid() }; using (UserForm f = new UserForm( u, EntityOperation.Add, new PropertyValueExists(_userCache.PropertyValueExists))) { if (f.ShowDialog() == DialogResult.OK) { _userCache.Add(u); Refresh(false); _unsavedChanges = true; } } }
private void SavePasswordOnCache() { var param = Connection.Instance.ConnectionParameter; UserCache myUser = GetUserCache(param.CompanyDb, param.UserName, false); User myUserComp = GetUser(param.CompanyDb, param.UserName, true); myUser.GetByUserName(param.CompanyDb, param.UserName); myUser.UserName = param.UserName; myUser.Password = new EncryptorWrapper <string>().EncodeToMD5(param.Password); myUser.PasswordCompany = myUserComp.Password; myUser.CompanyDb = param.CompanyDb; if (myUser.ID != 0) { myUser.Update(); } else { myUser.Add(); } }
/// <summary> /// Parses sub profile information given from the packet /// </summary> /// <param name="bot"></param> /// <param name="packet"></param> public void Parse(PalBot bot, Packet packet) { DataMap map; if (packet["IV"] != null && packet["RK"] != null) { int iv = int.Parse(packet["IV"]); int rk = iv != 0 ? int.Parse(packet["RK"]) : 0; map = new DataMap(); map.Deserialize(Static.PalringoEncoding.GetBytes(packet.Payload), iv, packet.Payload.Length - iv - rk); } else { map = new DataMap(Static.PalringoEncoding.GetBytes(packet.Payload)); } try { var contacts = map.GetValueMapAll("contacts"); if (contacts != null) { foreach (var item in contacts.Data) { UserId id; if (!UserId.TryParse(item.Key, out id)) { continue; } var cm = new DataMap(item.Value); if (UserCache.ContainsKey(id)) { UserCache[id].Parse(bot, cm); } else { var u = new User(id); u.Parse(bot, cm); UserCache.Add(id, u); } } } var groups = map.GetValueMap("group_sub"); if (groups != null) { foreach (var gm in groups.Data) { int id; if (!int.TryParse(gm.Key, out id)) { continue; } if (Groups.ContainsKey(id)) { Groups[id].Parse(bot, new DataMap(gm.Value)); } else { var gp = new Group { Id = id }; gp.Parse(bot, new DataMap(gm.Value)); Groups.Add(id, gp); bot.On.Trigger("gj", gp); } } } var ext = map.GetValueMap("ext"); if (ext != null) { Profile.Parse(bot, ext); } if (map != null) { Profile.Parse(bot, map); } } catch (Exception ex) { bot.On.Trigger("e", ex); } }