Добавьте файлы проекта.
This commit is contained in:
189
SvetoforVKBot/Models/Commands/Admin/SelectAdminCommand.cs
Normal file
189
SvetoforVKBot/Models/Commands/Admin/SelectAdminCommand.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
using VkNet.Model;
|
||||
using System.Collections.ObjectModel;
|
||||
using VkNet.Model.Attachments;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.Admin
|
||||
{
|
||||
public class SelectAdminCommand : Command
|
||||
{
|
||||
private const int ADMIN1 = 59111081;
|
||||
private const int ADMIN2 = 369217524;
|
||||
private const int ADMIN3 = 10160301;
|
||||
public override string Name => "{\"button\":\"selectAdminMenu\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
SalesFunnel salesFunnel = new SalesFunnel();
|
||||
//var keyboardBuilder = new KeyboardBuilder().Clear();
|
||||
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
|
||||
try
|
||||
{
|
||||
if (update.@object.message.from_id == ADMIN1 || update.@object.message.from_id == ADMIN2 || update.@object.message.from_id == ADMIN3 || update.@object.message.from_id == 178385801)
|
||||
{
|
||||
|
||||
//List<MediaAttachment> listVideo = new List<MediaAttachment>()
|
||||
//{
|
||||
// new VkNet.Model.Attachments.Video() { Id = 456239343, OwnerId = 59111081, AccessKey = "5530abb97b1da2077b" }
|
||||
//};
|
||||
//@params.Attachments = listVideo;
|
||||
|
||||
Uri URL = new Uri("https://docs.google.com/spreadsheets/d/1nWHvWufxDy6g2ZJtqd4K8MDM6Gh8OHWasRGXIyqbT2k/");
|
||||
Uri URLSHEET_ALL = new Uri("https://docs.google.com/spreadsheets/d/1jr68NfIrlz2bVsN-HZg0Kv2sSJ82J5G-EbtXl-YMK44/");
|
||||
Uri URLDOC = new Uri("https://docs.google.com/document/d/1DQcBuS9g6KYphJZRdcc-tdqgQ_oSvV2PsZt3U-pO_oo/");
|
||||
Uri URLDIALOGS = new Uri("https://vk.com/gim194717824");
|
||||
/*
|
||||
if (admin == 1)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton("📅Каталог мероприятий", "selectEvents-0-1", KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("➕Добавить мероприятие", "Добавить мероприятие", KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("Создать рассылку", "Создать рассылку", KeyboardButtonColor.Default)
|
||||
.AddLine()
|
||||
.AddButton("Статистика", "Статистика", KeyboardButtonColor.Default)
|
||||
.AddButton("Обращения", "Обращения", KeyboardButtonColor.Default);
|
||||
@params.Message = "Режим администратора. Выберите интересующее действие👇🏻";
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
//keyboardBuilder.AddButton("Открыть таблицу", URL, "open_link");
|
||||
var row = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URL,
|
||||
Label = "Заявки на консультацию",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row));
|
||||
|
||||
var row1 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URLSHEET_ALL,
|
||||
Label = "Все участники",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
|
||||
|
||||
row1 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URLDIALOGS,
|
||||
Label = "Перейти в диалоги",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
|
||||
|
||||
row1 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Type = KeyboardButtonActionType.OpenLink,
|
||||
Link = URLDOC,
|
||||
Label = "Инструкция",
|
||||
Payload = "{\"button\":\"selectOpenSheet\"}"
|
||||
},
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
|
||||
|
||||
var row2 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Label = "Статистика",
|
||||
Payload = "{\"button\":\"selectStatistic\"}",
|
||||
Type = KeyboardButtonActionType.Text},
|
||||
Color = KeyboardButtonColor.Primary
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row2));
|
||||
|
||||
|
||||
//var row3 = new List<MessageKeyboardButton>()
|
||||
//{
|
||||
// new MessageKeyboardButton() {
|
||||
// Action = new MessageKeyboardButtonAction(){
|
||||
// Label = "Личный кабинет специалиста",
|
||||
// Payload = "{\"button\":\"selectExpertLK\"}",
|
||||
// Type = KeyboardButtonActionType.Text},
|
||||
// Color = KeyboardButtonColor.Primary
|
||||
// }
|
||||
//};
|
||||
//listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row3));
|
||||
|
||||
var row4 = new List<MessageKeyboardButton>()
|
||||
{
|
||||
new MessageKeyboardButton() {
|
||||
Action = new MessageKeyboardButtonAction(){
|
||||
Label = "В начало",
|
||||
Payload = "{\"button\":\"startPL\"}",
|
||||
Type = KeyboardButtonActionType.Text},
|
||||
Color = KeyboardButtonColor.Default
|
||||
}
|
||||
};
|
||||
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row4));
|
||||
|
||||
var buttons = new ReadOnlyCollection<ReadOnlyCollection<MessageKeyboardButton>>(listButtons);
|
||||
|
||||
var keyboard = new MessageKeyboard()
|
||||
{
|
||||
Buttons = buttons,
|
||||
OneTime = false
|
||||
};
|
||||
|
||||
//@params.Attachments = listVideo;
|
||||
@params.Keyboard = keyboard;
|
||||
@params.UserId = chatId;
|
||||
@params.Message = "✅ Вы перешли в панель администратора. Выберите интересующее действие";
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectAdminCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
82
SvetoforVKBot/Models/Commands/Admin/SelectGetPhotoCommand.cs
Normal file
82
SvetoforVKBot/Models/Commands/Admin/SelectGetPhotoCommand.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using VkNet;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.Admin
|
||||
{
|
||||
public class SelectGetPhotoCommand : Command
|
||||
{
|
||||
public override string Name => "/getphoto";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
string str = "";
|
||||
|
||||
try
|
||||
{
|
||||
//string[] payload = update.@object.message.text.Split('-');
|
||||
string response = "";
|
||||
|
||||
if (chatId != 59111081) return;
|
||||
|
||||
foreach (var att in update.@object.message.attachments)
|
||||
{
|
||||
switch (att.type)
|
||||
{
|
||||
case "photo":
|
||||
var usPhoto = client.Photo.GetMessagesUploadServer(peerId: 0);
|
||||
var strArray = att.photo.sizes[att.photo.sizes.Count - 1].url.Split('.');
|
||||
|
||||
response = UploadFile(
|
||||
serverUrl: usPhoto.UploadUrl,
|
||||
file: att.photo.sizes[att.photo.sizes.Count - 1].url,
|
||||
fileExtension: strArray[strArray.Length - 1]).Result;
|
||||
|
||||
foreach (var a in client.Photo.SaveMessagesPhoto(response))
|
||||
{
|
||||
|
||||
str = "{\"id\": " + a.Id +
|
||||
", \"owner_id\": " + a.OwnerId +
|
||||
", \"access_key\": \"" + a.AccessKey + "\"}";
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case "video":
|
||||
str = "{\"id\": " + att.video.id +
|
||||
", \"owner_id\": " + att.video.owner_id +
|
||||
", \"access_key\": \"" + att.video.access_key + "\"}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@params.Message = str;
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectGetPhotoCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
114
SvetoforVKBot/Models/Commands/Admin/SelectStatisticCommand.cs
Normal file
114
SvetoforVKBot/Models/Commands/Admin/SelectStatisticCommand.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using SvetoforVKBot.Models.Updates;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using VkNet;
|
||||
using VkNet.Enums.SafetyEnums;
|
||||
using VkNet.Model.Keyboard;
|
||||
using VkNet.Model.RequestParams;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands.Admin
|
||||
{
|
||||
public class SelectStatisticCommand : Command
|
||||
{
|
||||
private const int ADMIN1 = 59111081;
|
||||
private const int ADMIN2 = 10160301;
|
||||
private const int ADMIN3 = 369217524;
|
||||
private const int ADMIN4 = 178385801;
|
||||
//chatId == 59111081 || chatId == 10160301 || chatId == 369217524 || chatId == 178385801
|
||||
public override string Name => "{\"button\":\"selectStatistic\"}";
|
||||
|
||||
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
MessagesSendParams @params = new MessagesSendParams();
|
||||
var chatId = update.@object.message.from_id;
|
||||
string msg = "";
|
||||
double sumOrders = 0;
|
||||
DateTime dt;
|
||||
DateTime dt1;
|
||||
DateTime dt2;
|
||||
List<UserStats> userStats = new List<UserStats>();
|
||||
List<UserStats> userStats1 = new List<UserStats>();
|
||||
SalesFunnel salesFunnel = new SalesFunnel();
|
||||
|
||||
try
|
||||
{
|
||||
if (update.@object.message.from_id == ADMIN1 || update.@object.message.from_id == ADMIN2 || update.@object.message.from_id == ADMIN3 || update.@object.message.from_id == ADMIN4)
|
||||
{
|
||||
|
||||
userStats = db.Users.ToList().ConvertAll<UserStats>(x => new UserStats {
|
||||
chatId = x.chatId,
|
||||
sourses = JsonConvert.DeserializeObject<Sourses>(x.sourse),
|
||||
voronka = x.voronka,
|
||||
});
|
||||
|
||||
/*SqlCommand getUsers = new SqlCommand("SELECT chatId, sourse, voronka FROM Users;", Con);
|
||||
SqlDataReader rgetUsers = getUsers.ExecuteReader();
|
||||
while (rgetUsers.Read())
|
||||
userStats.Add(new UserStats()
|
||||
{
|
||||
chatId = Convert.ToInt32(rgetUsers["chatId"]),
|
||||
sourses = JsonConvert.DeserializeObject<Sourses>(rgetUsers["sourse"].ToString()),
|
||||
voronka = rgetUsers["voronka"].ToString(),
|
||||
});
|
||||
rgetUsers.Close();*/
|
||||
|
||||
msg += "📊 Статистика \n" +
|
||||
"ВСЕГО: сег вч нед мес all\n";
|
||||
|
||||
foreach (var st in salesFunnel.stages)
|
||||
{
|
||||
dt = DateTime.Now;
|
||||
dt2 = DateTime.Now;
|
||||
|
||||
msg += st + ": " + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt.Date)).Count;
|
||||
|
||||
dt = dt.AddDays(-1);
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt.Date)).Count;
|
||||
|
||||
dt2 = dt2.AddDays(-7);
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt2.Date)).Count;
|
||||
dt2 = dt2.AddDays(7);
|
||||
|
||||
dt2 = dt2.AddMonths(-1);
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st) && u.sourses.sourses.Count > 0 &&
|
||||
u.sourses.sourses[0].dateTime.Date.Equals(dt2.Date)).Count;
|
||||
dt2 = dt2.AddMonths(1);
|
||||
|
||||
msg += "__" + userStats.FindAll(u => u.voronka.Equals(st)).Count;
|
||||
|
||||
msg += "\n";
|
||||
}
|
||||
|
||||
msg += "Всего пользователей: " + userStats.Count + "\n";
|
||||
msg += "\n";
|
||||
|
||||
@params.UserId = chatId;
|
||||
@params.Message = msg;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectStatisticCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
220
SvetoforVKBot/Models/Commands/Admin/SelectTestNotifyCommand.cs
Normal file
220
SvetoforVKBot/Models/Commands/Admin/SelectTestNotifyCommand.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
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.Admin
|
||||
{
|
||||
public class SelectTestNotifyCommand : Command
|
||||
{
|
||||
public override string Name => "/test";
|
||||
|
||||
public override void Execute(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 = "";
|
||||
int age = 0;
|
||||
int genderCoef = 0;
|
||||
double kkalResult = 0;
|
||||
double colorPercent = 0;
|
||||
double dayCoef = 0;
|
||||
double curDayKkal = 0;
|
||||
double kkalResultLow = 0;
|
||||
double kkalResultHigh = 0;
|
||||
try
|
||||
{
|
||||
Dictionary<int, string> tracks = new Dictionary<int, string>(7);
|
||||
tracks.Add(1, "Оптимизация питания");
|
||||
tracks.Add(2, "Снижение жировой массы");
|
||||
tracks.Add(3, "Увеличение мышечной массы");
|
||||
tracks.Add(4, "Персональный режим");
|
||||
|
||||
//-- Вот этот запрос лучше сработает на стороне
|
||||
db.Database.ExecuteSqlCommand("UPDATE Users SET choosenProducts = @choosenProducts, cart = @cart;",
|
||||
new object[] {
|
||||
new SqlParameter("@choosenProducts", "[]"),
|
||||
new SqlParameter("@cart", "{\"orders\":[]}")
|
||||
});
|
||||
|
||||
//--
|
||||
var user = db.Users.Single(usr => usr.chatId == 59111081);
|
||||
int id = user.id;
|
||||
string fio = user.fio;
|
||||
var birthday = user.birthday;
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
int choosenTrack = user.track;
|
||||
int height = user.height;
|
||||
int weight = user.weight;
|
||||
int gender = user.gender; // 1 - М / 2 - Ж
|
||||
var activityCoef = user.activityCoef;
|
||||
//--
|
||||
if ((DateTime.Now.Month >= birthday.Month) && (DateTime.Now.Day >= birthday.Day))
|
||||
age = DateTime.Now.Year - birthday.Year;
|
||||
else
|
||||
age = DateTime.Now.Year - birthday.Year - 1;
|
||||
|
||||
#region ccalCalculator
|
||||
Dictionary<int, string> days = new Dictionary<int, string>(7);
|
||||
days.Add(1, "Понедельник");
|
||||
days.Add(2, "Вторник");
|
||||
days.Add(3, "Среда");
|
||||
days.Add(4, "Четверг");
|
||||
days.Add(5, "Пятница");
|
||||
days.Add(6, "Суббота");
|
||||
days.Add(7, "Воскресенье");
|
||||
|
||||
Dictionary<int, string> gend = new Dictionary<int, string>(3);
|
||||
gend.Add(0, "Мужской");
|
||||
gend.Add(1, "Мужской");
|
||||
gend.Add(2, "Женский");
|
||||
|
||||
int curDay = (int)DateTime.Now.DayOfWeek;
|
||||
if (curDay == 0) curDay = 7;
|
||||
|
||||
int nextDay = curDay + 1;
|
||||
|
||||
if (nextDay == 8)
|
||||
nextDay = 1;
|
||||
|
||||
//if (weight == 0 || height == 0)
|
||||
//{
|
||||
// keyboardBuilder
|
||||
// .AddButton("📝Редактировать данные", "selectEditData-0", KeyboardButtonColor.Primary)
|
||||
// .AddLine()
|
||||
// .AddButton("Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
// @params.Message = "Не хватает данных о росте/весе.\n" +
|
||||
// "Нажмите \"📝Редактировать данные\" и заполните показатели.";
|
||||
|
||||
// @params.Keyboard = keyboardBuilder.Build();
|
||||
// @params.UserId = chatId;
|
||||
// @params.RandomId = GetRandomId();
|
||||
// client.Messages.SendAsync(@params);
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
if (gender == 1)
|
||||
{
|
||||
genderCoef = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
genderCoef = -161;
|
||||
}
|
||||
switch (choosenTrack)
|
||||
{
|
||||
case 1: //не изменяя веса
|
||||
colorPercent = 1;
|
||||
break;
|
||||
case 2:
|
||||
colorPercent = 0.75; //1 - 15%
|
||||
break;
|
||||
case 3:
|
||||
colorPercent = 1.2; //1 - 15%
|
||||
break;
|
||||
default:
|
||||
colorPercent = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 7; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 2:
|
||||
dayCoef = 0.8;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
dayCoef = 1.2;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
dayCoef = 0.9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
dayCoef = 1.1;
|
||||
break;
|
||||
|
||||
default:
|
||||
dayCoef = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
kkalResult = Math.Round((((10 * weight) + (6.25 * height) - (5 * age) + genderCoef) * activityCoef) * colorPercent * dayCoef);
|
||||
kkalResultHigh = Math.Round(kkalResult * 1.2);
|
||||
kkalResultLow = Math.Round(kkalResult * 0.9);
|
||||
|
||||
//if (i == nextDay)
|
||||
if (i == curDay)
|
||||
{
|
||||
curDayKkal = kkalResult;
|
||||
}
|
||||
}
|
||||
#endregion ccalCalculator
|
||||
|
||||
//-- неожиданно пришлось преобразовывать типы данных к инту от double)
|
||||
var curChatIdUser = db.Users.Single(usr => usr.chatId == chatId);
|
||||
curChatIdUser.kkal = Convert.ToInt32(curDayKkal);
|
||||
db.SaveChanges();
|
||||
|
||||
|
||||
//@params.Message = "🌙Добрый вечер!\n" +
|
||||
// $"Ваша норма калорий на завтра: {Math.Round(curDayKkal * 0.9)} - {Math.Round(curDayKkal * 1.2)}\n" +
|
||||
// "Мы подготовили для Вас блюда👇🏻";
|
||||
@params.Message = "☀Доброе утро!\n" +
|
||||
$"Ваша норма калорий на сегодня: {Math.Round(curDayKkal * 0.9)} - {Math.Round(curDayKkal * 1.2)}\n" +
|
||||
"Мы подготовили для Вас блюда👇🏻\n\n" +
|
||||
"Меню также доступно в Личном кабинете в разделе \"Дневной рацион\"";
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton($"Завтрак (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-1-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Обед (до {Math.Round(curDayKkal * 1.2 * 0.4)} ккал)", "selectPersonalMenu-2-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Перекус (до {Math.Round(curDayKkal * 1.2 * 0.1)} ккал)", "selectPersonalMenu-3-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton($"Ужин (до {Math.Round(curDayKkal * 1.2 * 0.3)} ккал)", "selectPersonalMenu-4-" + Math.Round(curDayKkal), KeyboardButtonColor.Primary)
|
||||
.AddLine()
|
||||
.AddButton("Личный кабинет", "startPL", KeyboardButtonColor.Default)
|
||||
.SetInline();
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = 59111081; //10160301;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "Ошибка в SelectTestNotifyCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user