public JsonResult UpdateUserInfo(MemberUpdate model) { if (!model.BirthDay.HasValue && !CurrentUser.BirthDay.HasValue) { return(Json(new Result() { success = false, msg = "生日必须填写" })); } //if (string.IsNullOrWhiteSpace(model.CellPhone) || string.IsNullOrWhiteSpace(CurrentUser.CellPhone)) //{ // return Json(new Result() { success = false, msg = "请先绑定手机号码" }); //} if (string.IsNullOrWhiteSpace(model.RealName)) { return(Json(new Result() { success = false, msg = "用户姓名必须填写" })); } model.Id = CurrentUser.Id; MemberApplication.UpdateMemberInfo(model); return(Json(new Result() { success = true, msg = "修改成功" })); }
/// <summary> /// Creates a new token member. /// </summary> /// <param name="memberId">the member ID</param> /// <param name="operations">the operations to apply</param> /// <param name="metadata">the metadata of the operations</param> /// <param name="signer">the signer used to sign the request</param> /// <returns>the created member</returns> public Task <ProtoMember> CreateMember( string memberId, IList <MemberOperation> operations, IList <MemberOperationMetadata> metadata, ISigner signer) { var update = new MemberUpdate { MemberId = memberId, Operations = { operations } }; var request = new UpdateMemberRequest { Update = update, UpdateSignature = new Signature { MemberId = memberId, KeyId = signer.GetKeyId(), Signature_ = signer.Sign(update) }, Metadata = { metadata } }; return(gateway.UpdateMemberAsync(request) .ToTask(response => response.Member)); }
public static UpdateMemberRequest ToUpdateMemberRequest( ProtoMember member, IList <MemberOperation> operations, ISigner signer, IList <MemberOperationMetadata> metadata) { var update = new MemberUpdate { MemberId = member.Id, PrevHash = member.LastHash, Operations = { operations } }; return(new UpdateMemberRequest { Update = update, UpdateSignature = new Signature { MemberId = member.Id, KeyId = signer.GetKeyId(), Signature_ = signer.Sign(update) }, Metadata = { metadata } }); }
public void SaveMember(Member member) { if (!member.IsTransient()) { return; } using (IDataGateway dataGateway = this.dataGatewayProvider.GetDataGateway()) { member.Id = dataGateway.Connection.Query <int>(@"insert into member(vkgroupid, name, gender, maritalstatus, birthday, birthmonth, birthyear, cityid, countryid, education, vkmemberid, status, isdeleted) values (@VkGroupId, @Name, @Gender, @MaritalStatus, @BirthDay, @BirthMonth, @BirthYear, @CityId, @CountryId, @Education, @VkMemberId, @Status, @IsDeleted) RETURNING id", this.Flatten(member)).First(); if (member.Interests != null && member.Interests.Count > 0) { foreach (var interest in member.Interests) { this.InsertInterest(interest, dataGateway); } } var update = new MemberUpdate { VkMemberId = member.VkMemberId, VkGroupId = member.VkGroupId, CreatedDate = DateTime.UtcNow, IsNew = true }; update.Id = dataGateway.Connection.Query <int>(@"INSERT INTO memberupdate(vkgroupid, vkmemberid, createddate, isnew) VALUES (@vkGroupId, @vkMemberId, @createdDate, @isNew) RETURNING id", update).First(); } }
public MemberUpdatedEvent( [JsonProperty(Required = Required.Always)] HashId serverId, [JsonProperty(Required = Required.Always)] MemberUpdate userInfo ) => (ServerId, UserInfo) = (serverId, userInfo);
public async Task <Member> UpdateMember(string org, Guid memberId, MemberUpdate data) { var req = new HttpRequestMessage(new HttpMethod("PATCH"), $"/{org}/members/{memberId}/").WithJsonContent(data); req.Headers.Authorization = await tokenProvider.AcquireAuthHeader(); var response = await api.SendAsync(req); await response.EnsureSuccess(); return(await response.Content.ReadAsAsync <Member>()); }
/// <summary> /// 保存个人信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public object SaveUserInfo(MemberUpdate model) { CheckUserLogin(); if (string.IsNullOrWhiteSpace(model.RealName)) { return(ErrorResult("真实姓名必须填写")); } if (!string.IsNullOrWhiteSpace(model.Photo)) { model.Photo = UploadPhoto(model.Photo); } model.Id = CurrentUser.Id; MemberApplication.UpdateMemberInfo(model); return(Json(new { success = true, msg = "修改成功" })); }
public void UpdateMember(Member member, MemberChangeContext context = null) { if (member == null) { return; } MemberChangeContext changeContext = context ?? MemberChangeContext.Default; using (IDataGateway dataGateway = this.dataGatewayProvider.GetDataGateway()) { if (changeContext.IsMemberChanged) { dataGateway.Connection.Execute(@"update member set vkgroupid = @VkGroupId, name = @Name, gender = @Gender, maritalstatus = @MaritalStatus, birthday = @BirthDay, birthmonth = @BirthMonth, birthyear = @BirthYear, cityid = @CityId, countryid = @CountryId, education = @Education, vkmemberid = @VkMemberId, status = @Status, isdeleted = @IsDeleted where id = @Id", this.Flatten(member)); } var update = new MemberUpdate { VkMemberId = member.VkMemberId, VkGroupId = member.VkGroupId, CreatedDate = DateTime.UtcNow, IsNew = false }; update.Id = dataGateway.Connection.Query <int>(@"INSERT INTO memberupdate(vkgroupid, vkmemberid, createddate, isnew) VALUES (@vkGroupId, @vkMemberId, @createdDate, @isNew) RETURNING id", update).First(); if (!changeContext.IsMemberInterestsChanged) { return; } if (member.Interests != null && member.Interests.Count > 0) { foreach (var interest in member.Interests) { if (interest.IsTransient()) { this.InsertInterest(interest, dataGateway); } else { this.UpdateInterest(interest, dataGateway); } } } } }
/// <summary> /// 更新会员信息新方法必须 /// </summary> /// <param name="model"></param> public static void UpdateMemberInfo(MemberUpdate model) { var mm = _iMemberService.GetMember(model.Id);//先查询 // mm.Email = model.Email; // mm.CellPhone = model.CellPhone; mm.RealName = model.RealName; mm.Nick = model.Nick; mm.QQ = model.QQ; if (model.BirthDay.HasValue) { mm.BirthDay = model.BirthDay; } mm.Occupation = model.Occupation; mm.Sex = model.Sex; _iMemberService.UpdateMemberInfo(mm); }
public override void MemberUpdated(TwilioChatClient client, Channel channel, Member member, MemberUpdate updated) { Logger.Info($"ChatClient: {client}", $"Channel: {channel.Sid} MemberUpdated: {member.Sid}, reason: {updated}"); }
public override void MemberUpdated(TwilioChatClient client, Channel channel, Member member, MemberUpdate updated) { Logger.Info($"ChatClient: {client}", $"Channel: {channel.Sid} MemberUpdated: {member.Sid}, reason: {updated}"); if (updated == MemberUpdate.Attributes) { Logger.Info($"ChatClient: {client}", $"Member attributes: {member.Attributes.ToDebugLog()}"); } }
//TODO: Typing Start //TODO: Integrations //TODO: User Updates //TODO: Voice Chat private void GatewayMessageHandler(string eventName, string payload) { _Logger?.Debug($"{eventName} - {payload}"); var eventValue = (Events)Enum.Parse(typeof(Events), eventName); var eventPayload = JObject.Parse(payload); switch (eventValue) { case Events.READY: { var guilds = eventPayload["guilds"] as JArray; foreach (var guild in guilds) { var g = new Guild { Id = guild["id"].ToString(), Unavailable = guild["unavailable"].ToObject <bool>() }; Guilds.Add(g.Id, g); } break; } case Events.GUILD_CREATE: { Guild g = null; if (Guilds.ContainsKey(eventPayload["id"].ToString())) { g = Guilds[eventPayload["id"].ToString()]; } else { g = new Guild() { Id = eventPayload["id"].ToString() }; Guilds.Add(g.Id, g); } JsonConvert.PopulateObject(payload, g); foreach (var channel in g.Channels) { if (!Channels.ContainsKey(channel.Key)) { Channels.Add(channel.Key, channel.Value); } channel.Value.Guild_Id = g.Id; channel.Value.Guild = g; } foreach (var member in g.Members) { if (!Users.ContainsKey(member.Key)) { Users.Add(member.Key, member.Value.User); } else if (member.Value.User != Users[member.Key]) { member.Value.User = Users[member.Key]; } member.Value.Guild = g; } foreach (var presence in g.Presences.Values) { presence.User = Users[presence.User.Id]; } g.UpdateAllUserPermissions(); GuildCreated?.Invoke(g); break; } case Events.GUILD_UPDATE: { var g = Guilds[eventPayload["id"].ToString()]; // TODO: Double check that this is the correct behavior. JsonConvert.PopulateObject(payload, g); GuildUpdated?.Invoke(g); break; } case Events.GUILD_DELETE: { var g = Guilds[eventPayload["id"].ToString()]; Guilds.Remove(eventPayload["id"].ToString()); GuildDeleted?.Invoke(g); break; } case Events.CHANNEL_CREATE: { var c = eventPayload.ToObject <GuildChannel>(); var g = Guilds[c.Guild_Id]; c.Guild = g; g.Channels.Add(c.Id, c); Channels.Add(c.Id, c); ChannelCreate?.Invoke(g, c); break; } case Events.CHANNEL_UPDATE: { var g = Guilds[eventPayload["guild_id"].ToString()]; var c = g.Channels[eventPayload["id"].ToString()]; JsonConvert.PopulateObject(payload, c); ChannelUpdate?.Invoke(g, c); break; } case Events.CHANNEL_DELETE: { var g = Guilds[eventPayload["guild_id"].ToString()]; var c = g.Channels[eventPayload["id"].ToString()]; g.Channels.Remove(c.Id); Channels.Remove(c.Id); ChannelDelete?.Invoke(g, c); break; } case Events.GUILD_BAN_ADD: { // TODO: User knows about bans var g = Guilds[eventPayload["guild_id"].ToString()]; var m = g.Members[eventPayload["id"].ToString()]; Users[m.User.Id].Guilds.Remove(g); g.Members.Remove(m.User.Id); BanAdd?.Invoke(g, m.User); break; } case Events.GUILD_BAN_REMOVE: { var g = Guilds[eventPayload["guild_id"].ToString()]; BanRemove?.Invoke(g, eventPayload.ToObject <DiscordUser>()); break; } case Events.GUILD_EMOJIS_UPDATE: { var g = Guilds[eventPayload["guild_id"].ToString()]; g.Emojis.Clear(); JsonConvert.PopulateObject(payload, g); EmojiUpdate?.Invoke(g, eventPayload["emojis"].ToObject <List <Guild.Emoji> >()); break; } case Events.GUILD_MEMBER_ADD: { var g = Guilds[eventPayload["guild_id"].ToString()]; var m = eventPayload.ToObject <GuildMember>(); if (!Users.ContainsKey(m.User.Id)) { Users.Add(m.User.Id, m.User); } else { m.User = Users[m.User.Id]; } g.Members.Add(m.User.Id, m); m.User.Guilds.Add(g); m.Guild = g; g.UpdateUserPermission(m); MemberAdd?.Invoke(g, m); break; } case Events.GUILD_MEMBER_REMOVE: { var g = Guilds[eventPayload["guild_id"].ToString()]; var m = g.Members[eventPayload["user"]["id"].ToString()]; g.Members.Remove(m.User.Id); m.User.Guilds.Remove(g); MemberRemove?.Invoke(g, m); break; } case Events.GUILD_MEMBER_UPDATE: { var g = Guilds[eventPayload["guild_id"].ToString()]; var m = g.Members[eventPayload["user"]["id"].ToString()]; JsonConvert.PopulateObject(payload, m); g.UpdateUserPermission(m); MemberUpdate?.Invoke(g, m); break; } case Events.GUILD_MEMBERS_CHUNK: { var g = Guilds[eventPayload["guild_id"].ToString()]; var members = eventPayload["members"].ToObject <List <GuildMember> >(); foreach (var member in members) { if (Users.ContainsKey(member.User.Id)) { member.User = Users[member.User.Id]; } else { Users.Add(member.User.Id, member.User); } g.Members.Remove(member.User.Id); g.Members.Add(member.User.Id, member); } MemberChunkUpdate?.Invoke(g, members); break; } case Events.GUILD_ROLE_CREATE: { var g = Guilds[eventPayload["guild_id"].ToString()]; var r = eventPayload["role"].ToObject <Guild.Role>(); g.Roles.Add(r.Id, r); RoleCreate?.Invoke(g, r); break; } case Events.GUILD_ROLE_UPDATE: { var g = Guilds[eventPayload["guild_id"].ToString()]; var r = g.Roles[eventPayload["role"]["id"].ToString()]; JsonConvert.PopulateObject(eventPayload["role"].ToString(), r); RoleUpdate?.Invoke(g, r); break; } case Events.GUILD_ROLE_DELETE: { var g = Guilds[eventPayload["guild_id"].ToString()]; var r = g.Roles[eventPayload["role_id"].ToString()]; g.Roles.Remove(r.Id); RoleDelete?.Invoke(g, r); break; } case Events.MESSAGE_CREATE: { var message = eventPayload.ToObject <Message>(); var c = Channels[message.Channel_Id]; message.Channel = c; if (string.IsNullOrEmpty(message.Webhook_Id)) { if (Users.ContainsKey(message.Author.Id)) { message.Author = Users[message.Author.Id]; } } MessageCreate?.Invoke(c, message); break; } case Events.MESSAGE_UPDATE: { var message = eventPayload.ToObject <Message>(); var c = Channels[message.Channel_Id]; MessageUpdate?.Invoke(c, message); break; } case Events.MESSAGE_DELETE: { var message = eventPayload.ToObject <Message>(); var c = Channels[message.Channel_Id]; MessageDelete?.Invoke(c, message); break; } case Events.MESSAGE_DELETE_BULK: { var messages = eventPayload.ToObject <List <Message> >(); var c = Channels[eventPayload["channel_id"].ToString()]; MessagesBulkDelete?.Invoke(c, messages); break; } case Events.PRESENCE_UPDATE: { var presense = eventPayload.ToObject <Guild.Presence>(); var g = Guilds[eventPayload["guild_id"].ToString()]; if (g.Presences.ContainsKey(presense.User.Id)) { var p = g.Presences[presense.User.Id]; p.Game = presense.Game; p.Status = presense.Status; presense = p; } else { presense.User = Users[presense.User.Id]; g.Presences.Add(presense.User.Id, presense); } PresenceUpdate?.Invoke(g, presense); break; } } }