Добавьте файлы проекта.

This commit is contained in:
Daria
2021-10-19 06:04:52 +03:00
parent 6ee25d0f59
commit eab3081ec2
187 changed files with 100839 additions and 0 deletions

View File

@@ -0,0 +1,122 @@
using SvetoforVKBot.Models.Commands;
using SvetoforVKBot.Models.Commands.Registration;
using SvetoforVKBot.Models.Updates;
using System;
using System.Data.SqlClient;
using System.Security.Cryptography;
using VkNet;
using VkNet.Model.RequestParams;
using System.Text.RegularExpressions;
using SvetoforVKBot.Models.Commands.LK;
using SvetoforVKBot.Models.Commands.LK.Reports;
using SvetoforVKBot.Models.Commands.LK.Consultation;
using SvetoforVKBot.Models.Commands.LK.EditData;
using System.Linq;
namespace SvetoforVKBot.Models.Dop
{
public class CheckTag
{
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
{
var chatId = update.@object.message.from_id;
MessagesSendParams @params = new MessagesSendParams();
string tag = "";
Regex regex = new Regex("[^0-9]");
try
{
tag = db.Users.Single(u => u.chatId == chatId).tag.Trim();
switch (tag)
{
case "Вопрос":
GetAskQuestionsCommand getAskQuestions = new GetAskQuestionsCommand();
getAskQuestions.Execute(update, client, db);
return;
case "Подписчик - Регистрация - Пол":
GetGenderCommand getGender = new GetGenderCommand();
getGender.Execute(update, client, db);
return;
case "Регистрация - Корпус":
GetKorpusCommand getKorpus = new GetKorpusCommand();
getKorpus.Execute(update, client, db);
return;
case "Подписчик - Регистрация - ФИО":
GetFIOCommand getFIOCommand = new GetFIOCommand();
getFIOCommand.Execute(update, client, db);
return;
case "Регистрация - Возраст":
GetAgeCommand getAgeCommand = new GetAgeCommand();
getAgeCommand.Execute(update, client, db);
return;
case "Личный кабинет - Изменить вес":
GetWeightCommand getWeight = new GetWeightCommand();
getWeight.Execute(update, client, db);
return;
case "Личный кабинет - Изменить рост":
GetHeightCommand getHeight = new GetHeightCommand();
getHeight.Execute(update, client, db);
return;
case "Подписчик - Регистрация - ДР - Год":
case "Личный кабинет - ДР - Год":
GetDRYearCommand getDRYear = new GetDRYearCommand();
getDRYear.Execute(update, client, db);
return;
case "Подписчик - Регистрация - Телефон":
GetPhoneCommand getPhone = new GetPhoneCommand();
getPhone.Execute(update, client, db);
return;
case "Консультация - Вопрос":
GetConsultationCommand getConsultation = new GetConsultationCommand();
getConsultation.Execute(update, client, db);
return;
case "Отчет - Комменнт":
GetReportCommentCommand getReport = new GetReportCommentCommand();
getReport.Execute(update, client, db);
return;
case "Личный кабинет - ФИО":
GetEditFIOCommand getEditFIO = new GetEditFIOCommand();
getEditFIO.Execute(update, client, db);
return;
case "Личный кабинет - Телефон":
GetEditPhoneCommand getEditPhone = new GetEditPhoneCommand();
getEditPhone.Execute(update, client, db);
return;
}
}
catch (Exception ee)
{
@params.Message = "‼Ошибка в CheckTag: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
private int GetRandomId()
{
var intBytes = new byte[4];
Rng.GetBytes(intBytes);
return BitConverter.ToInt32(intBytes, 0);
}
}
}

View File

@@ -0,0 +1,72 @@
using SvetoforVKBot.Models.Updates;
using System;
using System.Data.SqlClient;
using VkNet;
using VkNet.Model.RequestParams;
using System.Security.Cryptography;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Linq;
namespace SvetoforVKBot.Models.Dop
{
public class GetData
{
public void updateUser(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
{
var chatId = update.@object.message.from_id;
MessagesSendParams @params = new MessagesSendParams();
try
{
var ids = new long[] { chatId };
var user = client.Users.Get(ids);
var lastName = user[0].LastName;
var firstName = user[0].FirstName;
var checkUser = db.Users.FirstOrDefault(u => u.chatId == chatId);
if(checkUser!=null)
{
checkUser.firstName = firstName;
checkUser.lastName = lastName;
}
else
{
db.Users.Add(new Data.Users()
{
chatId = chatId,
firstName = firstName,
lastName = lastName,
sourse = JsonConvert.SerializeObject(new Sourses()
{
sourses = new List<Sourse>() { new Sourse() { name = "main", dateTime = DateTime.Now } }
})
});
}
db.SaveChanges();
}
catch (Exception ee)
{
@params.Message = "‼Ошибка в GetData: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
private int GetRandomId()
{
var intBytes = new byte[4];
Rng.GetBytes(intBytes);
return BitConverter.ToInt32(intBytes, 0);
}
}
}

View File

@@ -0,0 +1,88 @@
using SvetoforVKBot.Models.Updates;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
using VkNet;
using VkNet.Model.RequestParams;
namespace SvetoforVKBot.Models.Dop
{
public class SourceUpdate
{
public void Execute(RootObject update, VkApi client, SqlConnection Con)
{
var chatId = update.@object.message.from_id;
MessagesSendParams @params = new MessagesSendParams();
string sourse = "";
try
{
SqlCommand getSourses = new SqlCommand("SELECT sourse FROM Users WHERE chatId = @chatId;", Con);
getSourses.Parameters.AddWithValue("@chatId", chatId);
SqlDataReader rgetSourses = getSourses.ExecuteReader();
rgetSourses.Read();
var jsSourses = JsonConvert.DeserializeObject<Sourses>(rgetSourses["sourse"].ToString());
rgetSourses.Close();
switch (update.@object.message.@ref)
{
case "adv":
sourse = "adv";
break;
case "afisha":
sourse = "afisha";
break;
case "quest":
sourse = "quest";
break;
case "project":
sourse = "project";
break;
case "faq":
sourse = "faq";
break;
default:
sourse = "referal";
break;
}
if (jsSourses.sourses.FindAll(s => s.name != ("main")).Count == 0)
jsSourses.sourses = new List<Sourse>() { new Sourse() { name = sourse, dateTime = DateTime.Now } };
SqlCommand updUser = new SqlCommand("UPDATE Users SET sourse = @sourse WHERE chatId = @chatId;", Con);
updUser.Parameters.AddWithValue("@chatId", chatId);
updUser.Parameters.AddWithValue("@sourse", JsonConvert.SerializeObject(jsSourses));
updUser.ExecuteNonQuery();
}
catch (Exception ee)
{
@params.Message = "‼Ошибка в SourceUpdate: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081; //30103442;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
public int GetRandomId()
{
var intBytes = new byte[4];
Rng.GetBytes(intBytes);
return BitConverter.ToInt32(intBytes, 0);
}
}
}