Добавьте файлы проекта.
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
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 SelectExpertLKCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectExpertLK\"}";
|
||||
|
||||
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<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
try
|
||||
{
|
||||
@params.Message = "Личный кабинет специалиста.\n";
|
||||
|
||||
//вот это
|
||||
chatIds = db.PersonalConsultations.Where(c => c.chatId == chatId && c.state == 1)?
|
||||
.ToList().ConvertAll<int>(el => el.chatId);
|
||||
//вместо этого
|
||||
//SqlCommand getCons = new SqlCommand("SELECT * FROM PersonalConsultation WHERE chatId = @chatId AND state = 1;", Con);
|
||||
//getCons.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCons = getCons.ExecuteReader();
|
||||
//if (rgetCons.HasRows)
|
||||
//{
|
||||
// while (rgetCons.Read())
|
||||
// chatIds.Add(Convert.ToInt32(rgetCons["chatId"]));
|
||||
|
||||
// rgetCons.Close();
|
||||
//}
|
||||
//else
|
||||
// rgetCons.Close();
|
||||
|
||||
if (chatIds.Count > 0)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Участники: " + chatIds.Count.ToString(), "selectParticipants", KeyboardButtonColor.Positive)
|
||||
.AddButton("Вопросы", "selectExQuestions", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "selectAdminMenu", KeyboardButtonColor.Default);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("Участники", "selectExpertLK", KeyboardButtonColor.Primary)
|
||||
.AddButton("Вопросы", "selectExQuestions", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Назад", "selectAdminMenu", KeyboardButtonColor.Default);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectExpertLKCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
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<List<string>>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
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 SelectParticipantsCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectParticipants\"}";
|
||||
|
||||
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<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
string name = "";
|
||||
try
|
||||
{
|
||||
@params.Message = "Выберите участника.\n";
|
||||
|
||||
//SqlCommand getCons = new SqlCommand("SELECT * FROM PersonalConsultation WHERE chatId = @chatId;", Con);
|
||||
//getCons.Parameters.AddWithValue("@chatId", chatId);
|
||||
//SqlDataReader rgetCons = getCons.ExecuteReader();
|
||||
//if (rgetCons.HasRows)
|
||||
//{
|
||||
// while (rgetCons.Read())
|
||||
// chatIds.Add(Convert.ToInt32(rgetCons["chatId"]));
|
||||
|
||||
// rgetCons.Close();
|
||||
//}
|
||||
//else
|
||||
// rgetCons.Close();
|
||||
|
||||
//if (chatIds.Count > 0)
|
||||
//{
|
||||
// foreach (var c in chatIds)
|
||||
// {
|
||||
// SqlCommand getUser = new SqlCommand("SELECT * FROM Users WHERE chatId = @chatId;", Con);
|
||||
// getUser.Parameters.AddWithValue("@chatId", c);
|
||||
// SqlDataReader rgetUser = getUser.ExecuteReader();
|
||||
// while (rgetUser.Read())
|
||||
// users.Add(new UserObject()
|
||||
// {
|
||||
// id = Convert.ToInt32(rgetUser["id"]),
|
||||
// chatId = Convert.ToInt32(rgetUser["chatId"]),
|
||||
// fio = rgetUser["fio"].ToString(),
|
||||
// birthday = DateTime.Parse(rgetUser["birthday"].ToString()),
|
||||
// });
|
||||
|
||||
// rgetUser.Close();
|
||||
// }
|
||||
|
||||
// int btnRow = 0;
|
||||
|
||||
// foreach (var u in users)
|
||||
// {
|
||||
// if (u.fio.Length >= 36)
|
||||
// name = u.fio.Substring(0, 35) + "...";
|
||||
// else
|
||||
// name = u.fio;
|
||||
|
||||
|
||||
// keyboardBuilder
|
||||
// .AddButton(name, "selectParticipantInfo-"+ u.id, KeyboardButtonColor.Primary)
|
||||
// .AddLine();
|
||||
|
||||
// btnRow++;
|
||||
// if (btnRow == 8)
|
||||
// break;
|
||||
// }
|
||||
// keyboardBuilder
|
||||
// .AddButton("Назад", "selectExpertLK", KeyboardButtonColor.Default);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// keyboardBuilder
|
||||
// .AddButton("Назад", "selectExpertLK", KeyboardButtonColor.Default);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectParticipantsCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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 SelectUpPersonalPlanCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectPersonalPlan-";
|
||||
|
||||
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<UserObject> users = new List<UserObject>();
|
||||
List<int> chatIds = new List<int>();
|
||||
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 = user.chatId;
|
||||
string fio = user.fio;
|
||||
|
||||
user.personal = 1;
|
||||
db.Entry(db.PersonalConsultations.Where(el => el.chatId == uChatId)).Property("state").CurrentValue = 2;
|
||||
db.SaveChanges();
|
||||
|
||||
//SqlCommand updTag = new SqlCommand("UPDATE Users SET personal = @personal WHERE chatId = @chatId;", Con);
|
||||
//updTag.Parameters.AddWithValue("@chatId", uChatId);
|
||||
//updTag.Parameters.AddWithValue("@personal", 1);
|
||||
//updTag.ExecuteNonQuery();
|
||||
|
||||
//SqlCommand updState = new SqlCommand("UPDATE PersonalConsultation SET state = @state WHERE chatId = @chatId;", Con);
|
||||
//updState.Parameters.AddWithValue("@chatId", uChatId);
|
||||
//updState.Parameters.AddWithValue("@state", 2);
|
||||
//updState.ExecuteNonQuery();
|
||||
|
||||
@params.Message = "✅Персональный режим для участника " + fio + " включен";
|
||||
|
||||
keyboardBuilder
|
||||
//.AddButton("Вкл. персональный режим", "selectPersonalPlan-", 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 = "Ошибка в SelectUpPersonalPlanCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user