public void EvaluateState(string id) { var dbName = dbNameProvider.GetDBName("PeopleAndGroups"); var currentState = GetStateFromId(id); var statesChanges = new Dictionary <string, string> { [""] = "0", ["0"] = "1", ["1"] = "2", ["2"] = "3", ["3"] = "3" }; using (var connection = new SQLiteConnection(string.Format("Data Source={0};", dbName))) { connection.Open(); using (var command = new SQLiteCommand( string.Format("UPDATE PeopleAndGroups SET State='{0}' WHERE ChatID='{1}'", statesChanges[currentState], id), connection)) { try { ; command.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e); } } } }
public Lesson[] GetTimetableForGroupForCurrentDay(string group, DateTime day) { var dbName = dbNameProvider.GetDBName("TimeTable", extension); var days = new Dictionary <string, string> { ["Monday"] = "Понедельник", ["Tuesday"] = "Вторник", ["Wednesday"] = "Среда", ["Thursday"] = "Четверг", ["Friday"] = "Пятница", ["Saturday"] = "Суббота", ["Sunday"] = "Воскресенье" }; using (var parser = new TextFieldParser(dbName)) { parser.SetDelimiters(";"); while (!parser.EndOfData) { var fields = parser.ReadFields(); for (var i = 0; i < fields.Length - 2; i += 3) { if (fields[i] == days[day.DayOfWeek.ToString()] && fields[i + 1] == group) { return(ParseTimeTable(fields[i + 2], day)); } } } } return(new Lesson[0]); }
public Lesson[] GetTimetableForGroupForCurrentDay(string groupName, DateTime day) { var dbName = dbNameProvider.GetDBName("TimeTable"); var days = new Dictionary <string, string> { ["Monday"] = "Понедельник", ["Tuesday"] = "Вторник", ["Wednesday"] = "Среда", ["Thursday"] = "Четверг", ["Friday"] = "Пятница", ["Saturday"] = "Суббота", ["Sunday"] = "Воскресенье" }; using (var connection = new SQLiteConnection(string.Format("Data Source={0};", dbName))) { connection.Open(); var command = new SQLiteCommand(string.Format("SELECT timetable FROM TimeTable WHERE group_='{0}' AND dayOfWeek='{1}'", groupName, days[day.DayOfWeek.ToString()]), connection); var reader = command.ExecuteReader(); foreach (DbDataRecord record in reader) { var timetableString = record["timetable"].ToString(); return(ParseTimeTable(timetableString, day)); } return(new Lesson[0]); } }
public Link[] GetActualLinksForGroup(string group) { var dbName = dbNameProvider.GetDBName("link", extension); using (var parser = new TextFieldParser(dbName)) { parser.SetDelimiters(","); while (!parser.EndOfData) { var fields = parser.ReadFields(); if (fields[0] != @group) { continue; } var notParsedLinks = fields[1]; return(new ParseMethods().ParseLinks(notParsedLinks.Replace(@"\n", "\n"))); } } return(new Link[0]); }
private string GetActualLinksForGroupInString(string group) { var dbName = dbNameProvider.GetDBName("link"); using (var connection = new SQLiteConnection(string.Format("Data Source={0};", dbName))) { connection.Open(); using (var command = new SQLiteCommand(string.Format("SELECT links FROM Links WHERE GROUP_='{0}'", group), connection)) { using (var reader = command.ExecuteReader()) { var emptyLinks = new Link[0]; foreach (DbDataRecord record in reader) { var notParsedLinks = record["links"].ToString(); return(notParsedLinks); } return(""); } } } }
public void EvaluateState(string id) { var group = GetGroupFromId(id); var prevState = GetStateFromId(id); var states = new Dictionary <string, string> { [""] = "0", ["0"] = "1", ["1"] = "2", ["2"] = "3", ["3"] = "3" }; var platform = GetPlatformFromId(id); var dbName = dbNameProvider.GetDBName("PeopleAndGroups", "csv"); RewriteFields(id, group, states[prevState], platform, dbName); }