public override Task <TaskListResponse> GetTeamSpecificTasks(TeamDescription request, ServerCallContext context) { var respList = new TaskListResponse(); var teamID = -1; _dbConnection.Open(); var command = "SELECT TeamID FROM Worker WHERE WorkerID =" + request.Index; var newCommand = new SqlCommand(command, _dbConnection); var dataReader = newCommand.ExecuteReader(); if (dataReader.Read()) { teamID = dataReader.GetInt32(0); command = "SELECT Team, TeamID, Status, Text FROM ScheduleItem WHERE Status = '" + request.Name + "' AND TeamID =" + teamID; newCommand = new SqlCommand(command, _dbConnection); dataReader = newCommand.ExecuteReader(); while (dataReader.Read()) { respList.Tasks.Add(new MessagesPack.Task { Team = dataReader.GetString(0), TeamID = dataReader.GetInt32(1), Status = dataReader.GetString(2), Text = dataReader.GetString(3) }); } } dataReader.Close(); _dbConnection.Close(); return(System.Threading.Tasks.Task.FromResult(respList)); }
public override Task <WorkerEventResponse> RemoveTeam(TeamDescription request, ServerCallContext context) { DBConnection.Open(); String command = "DELETE FROM Team WHERE TeamName =" + request.Name; SqlCommand newCommand = new SqlCommand(command, DBConnection); newCommand.ExecuteNonQuery(); DBConnection.Close(); return(System.Threading.Tasks.Task.FromResult(new WorkerEventResponse { State = true, Msg = "Team deleted sucesfully!" })); }
public static List <ReplayDescription> GetListOfReplays(Guid accountID) { try { List <ReplayDescription> userreplays = new List <ReplayDescription>(); List <Game> usergames = (from g in db.Game where g.Creator_ID == accountID select g).ToList <Game>(); foreach (Game g in usergames) { List <TeamDescription> teamsingame = new List <TeamDescription>(); foreach (Team t in (from t in db.Teams where t.GameGame_ID == g.Game_ID select t)) { TeamDescription tdesc = new TeamDescription(); tdesc.ID = t.Team_ID; tdesc.Intellects = new List <Guid>(); foreach (Intellect i in t.Intellects) { tdesc.Intellects.Add(i.Intellect_ID); } } ReplayDescription replay = new ReplayDescription(); replay.ID = g.Game_ID; replay.Name = g.Game_Name; replay.Teams = teamsingame; userreplays.Add(replay); } return(userreplays); } catch (Exception e) { return(null); } }
public override Task <WorkerEventResponse> RemoveTeam(TeamDescription request, ServerCallContext context) { _DbConnection.Open(); var command = "DELETE FROM Team WHERE TeamName = '" + request.Name + "'"; var newCommand = new SqlCommand(command, _DbConnection); try { newCommand.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); _DbConnection.Close(); } _DbConnection.Close(); return(System.Threading.Tasks.Task.FromResult(new WorkerEventResponse { State = true, Msg = "Team deleted successfully!" })); }
public override Task <TeamDescription> GetDepHead(DepartmentDescription request, ServerCallContext context) { TeamDescription headDesc = new TeamDescription(); DBConnection.Open(); String command = "SELECT WorkerID, Name FROM Worker WHERE DepartmentID =" + request.Index; SqlCommand newCommand = new SqlCommand(command, DBConnection); SqlDataReader dataReader = newCommand.ExecuteReader(); if (dataReader.Read()) { headDesc.Index = dataReader.GetInt32(0); headDesc.Name = dataReader.GetString(1); } else { headDesc.Index = -1; headDesc.Name = "None"; } dataReader.Close(); DBConnection.Close(); return(System.Threading.Tasks.Task.FromResult(headDesc)); }