using Newtonsoft.Json; using SvetoforVKBot.Models.Updates; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using System.Linq; using System.Security.Cryptography; using System.Text.RegularExpressions; using VkNet; using VkNet.Enums.SafetyEnums; using VkNet.Model.Attachments; using VkNet.Model.Keyboard; using VkNet.Model.RequestParams; namespace SvetoforVKBot.Models.Commands.ExpertLK { public class SelectParticipantInfoCommand : Command { public override string Name => "{\"button\":\"selectParticipantInfo-"; public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db) { } public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db) { var chatId = update.@object.message.from_id; MessagesSendParams @params = new MessagesSendParams(); var keyboardBuilder = new KeyboardBuilder().Clear(); List users = new List(); List chatIds = new List(); string name = ""; Regex regex = new Regex("[^0-9]"); try { string[] payload = update.@object.message.payload.Split('-'); int userId = Convert.ToInt32(regex.Replace(payload[1], "")); //@params.Message = "Выберите участника.\n"; var user = db.Users.Single(usr => usr.id == userId); int uChatId = Convert.ToInt32(user.chatId); string fio = user.fio; var birthday = user.birthday; var jsPhones = JsonConvert.DeserializeObject>(user.phone); @params.Message = "Участник:\n\n" + fio + "\n" + "Дата рождения: " + birthday.ToShortDateString() + "\n" + "Телефон: " + jsPhones[0]; keyboardBuilder .AddButton("Вкл. персональный режим", "selectPersonalPlan-" + userId, KeyboardButtonColor.Positive) .AddLine() .AddButton("Назад", "selectExpertLK", KeyboardButtonColor.Default); @params.Keyboard = keyboardBuilder.Build(); @params.UserId = chatId; @params.RandomId = GetRandomId(); client.Messages.SendAsync(@params); } catch (Exception ee) { @params.Message = "Ошибка в SelectParticipantInfoCommand: " + ee.Message; @params.Attachments = null; @params.Keyboard = null; @params.UserId = 59111081; @params.RandomId = GetRandomId(); client.Messages.SendAsync(@params); } } } }