protected void GroupMemberConnection(int addgroup_id) { // There is a Many to Many relationship between a person and the group // so we need to fill the group_member database table as well try { var addeduser = ctx.person.Where(p => p.username == ticket.Name).FirstOrDefault(); var addedgroup = ctx.group.Where(g => g.group_id == addgroup_id).FirstOrDefault(); var rightgrouprole = ctx.group_role.Where(gr => gr.@class == 1).SingleOrDefault(); int group_role_input = rightgrouprole.grouprole_id; if (addeduser != null && addedgroup != null) { var gm = new group_member { group_id = addedgroup.group_id, person_id = addeduser.person_id, grouprole_id = group_role_input }; addeduser.group_member.Add(gm); addedgroup.group_member.Add(gm); ctx.SaveChanges(); } } catch (Exception ex) { lbMessages.Text = ex.Message; } }
protected void btnConfirmArchiveProject_Click(object sender, EventArgs e) { try { string project_id = Request.QueryString["Project"]; int parsed_project_id = int.Parse(project_id); var rightproject = ctx.project.Where(pr => pr.project_id == parsed_project_id).SingleOrDefault(); if (rightproject.finished == false) { rightproject.finished = true; } else if (rightproject.finished == true) { rightproject.finished = false; } ctx.SaveChanges(); } catch (Exception ex) { lbMessages.Text = ex.Message; } }
protected void btnRemoveAssignmentMember_Click(object sender, EventArgs e) { string assignment_id = String.Empty; string project_id = String.Empty; try { assignment_id = Request.QueryString["Assignment"]; project_id = Request.QueryString["Project"]; int toremoveassignment = int.Parse(assignment_id); int toremoveproject = int.Parse(project_id); foreach (ListItem item in cblAssignmentMemberList.Items) { if (item.Selected == true) { var rightperson = ctx.person.Where(p => p.username == item.Text).SingleOrDefault(); var rightassignment = ctx.assignment.Where(amt => amt.amt_id == toremoveassignment).SingleOrDefault(); if (rightperson != null && rightassignment != null) { var assignmentcomponentpersons = rightperson.assignment_component_person.ToList(); foreach (var member in assignmentcomponentpersons) { var rightassignmentcomponentperson = ctx.assignment_component_person.Where(acompe => acompe.amtc_id == member.amtc_id).SingleOrDefault(); ctx.assignment_component_person.Remove(rightassignmentcomponentperson); } var rightassignmentperson = ctx.assignment_person.Where(aspe => aspe.person_id == rightperson.person_id && aspe.amt_id == rightassignment.amt_id && aspe.project_id == toremoveproject).SingleOrDefault(); // If the assignmentperson was found remove it from the database and redirect the user to the assignmnet page if (rightassignmentperson != null) { ctx.assignment_person.Remove(rightassignmentperson); ctx.SaveChanges(); Response.Redirect(String.Format(Request.ApplicationPath + "Assignment.aspx?Assignment={0}&Project={1}", rightassignment.amt_id, toremoveproject)); } } } } } catch (Exception ex) { lbMessages.Text = ex.Message; } }
public void SaveProjectName(string projectname) { try { ctx = new TeeMsEntities(); int project_id = int.Parse(this.Context.QueryString["Project"]); string newname = projectname; var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); var rightproject = ctx.project.Where(pr => pr.project_id == project_id).SingleOrDefault(); rightproject.name = newname; ctx.SaveChanges(); // Call updateProjectTitle method on the client side // For some reason this call to the client side is made only if the variable passed to the client side is the same as the current project name in the database Clients.OthersInGroup(rightproject.name + rightproject.project_id.ToString()).updateProjectName(newname); } catch (Exception ex) { throw ex; } }
// Method to call when a client reconnects to the hub public override async Task OnReconnected() { try { ctx = new TeeMsEntities(); var connectionlist = ctx.connection.ToList(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); foreach (var connection in connectionlist) { if (connection.person_id == rightperson.person_id) { var rightconnection = ctx.connection.Where(con => con.connection_id == connection.connection_id).SingleOrDefault(); rightconnection.connected = true; ctx.SaveChanges(); } } await base.OnReconnected(); } catch (Exception ex) { throw ex; } }
public async Task JoinGroup(string groupname) { try { ctx = new TeeMsEntities(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); var rightgroup = rightperson.group_member.Where(gm => gm.group.name == groupname).SingleOrDefault(); await Groups.Add(Context.ConnectionId, groupname + rightgroup.group_id.ToString()); rightconnection.group_id = rightgroup.group_id; ctx.SaveChanges(); Clients.Group(groupname + rightgroup.group_id.ToString()).broadcastMessage("ChatControl", rightperson.username + " Joined group: " + groupname); GetChatMembers(rightgroup.group.name); GetConversationMessages(rightgroup.group.name); } catch (Exception ex) { throw ex; } }
// Method to call when a client disconnects from the hub either gracefully or not public override async Task OnDisconnected(bool stopCalled) { try { ctx = new TeeMsEntities(); var connectionlist = ctx.connection.ToList(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); // We'll set the connection property in the database to false and enter the time of disconnect foreach (var connection in connectionlist) { if (connection.person_id == rightperson.person_id) { var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); rightconnection.connected = false; rightconnection.connection_time = DateTime.Now; ctx.SaveChanges(); } } await base.OnDisconnected(stopCalled); } catch (Exception ex) { throw ex; } }
public async Task LeaveGroup(string newgroup) { try { ctx = new TeeMsEntities(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); var rightgroup = rightconnection.group; await Groups.Remove(Context.ConnectionId, rightgroup.name + rightgroup.group_id.ToString()); rightconnection.group_id = null; ctx.SaveChanges(); ChatMemberLeft(rightgroup.name); Clients.Group(rightgroup.name + rightgroup.group_id.ToString()).broadcastMessage("ChatControl", rightperson.username + " Left group"); await JoinGroup(newgroup); } catch (Exception ex) { throw ex; } }
protected void SaveAsComment(string message, int personid, int projecttag) { try { ctx = new TeeMsEntities(); var rightperson = ctx.person.Where(p => p.person_id == personid).SingleOrDefault(); var rightproject = ctx.project.Where(pr => pr.project_tag == projecttag).SingleOrDefault(); IHubContext projectContext = GlobalHost.ConnectionManager.GetHubContext <ProjectHub>(); comment newcomment = new comment() { comment_content = message, person = rightperson, project = rightproject, creation_date = DateTime.Now }; ctx.comment.Add(newcomment); ctx.SaveChanges(); // Call updateComments method on the ProjectHub users client side projectContext.Clients.Group(rightproject.name + rightproject.project_id.ToString()).updateComments(); } catch (Exception ex) { throw ex; } }
public void SaveAssignmentComment(string commentcon) { try { ctx = new TeeMsEntities(); if (commentcon != String.Empty) { int project_id = int.Parse(this.Context.QueryString["Project"]); int assignment_id = int.Parse(this.Context.QueryString["Assignment"]); string username = Context.User.Identity.Name; var rightperson = ctx.person.Where(p => p.username == username).SingleOrDefault(); comment newcomment = new comment { comment_content = commentcon, creation_date = DateTime.Now, person_id = rightperson.person_id, project_id = project_id, amt_id = assignment_id }; ctx.comment.Add(newcomment); ctx.SaveChanges(); BroadcastUpdateAssignmentComments(); } } catch (Exception ex) { throw ex; } }
protected void btnDeleteMember_Click(object sender, EventArgs e) { string user_to_delete = rblGroupMembers.SelectedValue; string group_id = String.Empty; try { group_id = Request.QueryString["Group"]; int removefromgroup = int.Parse(group_id); var rightperson = ctx.person.Where(p => p.username == user_to_delete).SingleOrDefault(); var rightgroup = ctx.group.Where(g => g.group_id == removefromgroup).SingleOrDefault(); if (rightperson != null && rightgroup != null) { var rightgroupmember = ctx.group_member.Where(gm => gm.person_id == rightperson.person_id && gm.group_id == rightgroup.group_id).SingleOrDefault(); foreach (var projectperson in rightperson.project_person.ToList()) { if (projectperson.group_id == rightgroup.group_id) { ctx.project_person.Remove(projectperson); } } if (rightgroupmember != null) { ctx.group_member.Remove(rightgroupmember); ctx.SaveChanges(); Response.Redirect(String.Format(Request.ApplicationPath + "Group.aspx?Group={0}", rightgroup.group_id)); } } } catch (Exception ex) { lbMessages.Text = ex.Message; } }
// Method to call when a client connects to the hub and forms a hubproxy public override async Task OnConnected() { try { ctx = new TeeMsEntities(); int group_id = int.Parse(this.Context.QueryString["Group"]); var connectionlist = ctx.connection.ToList(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightgroup = ctx.group.Where(g => g.group_id == group_id).SingleOrDefault(); foreach (var connection in connectionlist) { if (connection.person_id == rightperson.person_id) { var rightconnection = ctx.connection.Where(con => con.connection_id == connection.connection_id).SingleOrDefault(); rightconnection.connected = true; ctx.SaveChanges(); } } var groupconnection = rightperson.group_member.Where(gm => gm.group_id == group_id).SingleOrDefault(); if (groupconnection != null) { await JoinGroup(rightgroup.name + rightgroup.group_id.ToString()); } if (rightgroup.name != String.Empty) { SendGroupName(rightgroup); } if (rightgroup.group_picture_url != String.Empty) { SendGroupImage(rightgroup); } await base.OnConnected(); } catch (Exception ex) { throw ex; } }
public void Send(string message) { try { if (Context.User.Identity.IsAuthenticated) { ctx = new TeeMsEntities(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); var rightgroup = rightconnection.group; message newmessage = new message() { person_id = rightperson.person_id, group_id = rightgroup.group_id, message_content = message, creation_date = DateTime.Now }; ctx.message.Add(newmessage); ctx.SaveChanges(); Regex regex = new Regex("#PRO(?<tag>[0-9]{1,3})"); Match tagmatch = regex.Match(message); if (tagmatch.Success) { string stringtag = tagmatch.Groups["tag"].Value; int projecttag = int.Parse(stringtag); SaveAsComment(message, rightperson.person_id, projecttag); } // Call the broadcastMessage method to update clients. Clients.Group(rightgroup.name + rightgroup.group_id.ToString()).broadcastMessage(rightperson.username, message); } } catch (Exception ex) { throw ex; } }
public async Task JoinGroup(string groupname) { try { ctx = new TeeMsEntities(); int group_id = int.Parse(this.Context.QueryString["Group"]); await Groups.Add(Context.ConnectionId, groupname); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); var rightgroup = ctx.group.Where(g => g.group_id == group_id).SingleOrDefault(); rightconnection.group_id = rightgroup.group_id; ctx.SaveChanges(); } catch (Exception ex) { throw ex; } }
public void SaveGroupImage(string group_imageurl) { try { ctx = new TeeMsEntities(); int group_id = int.Parse(this.Context.QueryString["Group"]); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); var rightgroup = ctx.group.Where(g => g.group_id == group_id).SingleOrDefault(); rightgroup.group_picture_url = group_imageurl; ctx.SaveChanges(); // Call updateProjectTitle method on the client side Clients.OthersInGroup(rightgroup.name + rightgroup.group_id.ToString()).updateGroupImage(group_imageurl); } catch (Exception ex) { throw ex; } }
public void SaveAssignmentDescription(string assignmentdescription) { try { ctx = new TeeMsEntities(); int project_id = int.Parse(this.Context.QueryString["Project"]); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightconnection = ctx.connection.Where(con => con.person_id == rightperson.person_id).SingleOrDefault(); var rightproject = ctx.project.Where(pr => pr.project_id == project_id).SingleOrDefault(); rightproject.description = assignmentdescription; ctx.SaveChanges(); // Call updateAssignmentDescription method on the clients side Clients.OthersInGroup(rightproject.name + rightproject.project_id.ToString()).updateAssignmentDescription(assignmentdescription); } catch (Exception ex) { throw ex; } }
protected int CreateNewProject() { // Initialize usercontentmanager class with the users username UserContentManager contentmanager = new UserContentManager(ticket.Name); string projectname = txtProjectName.Text; string projectdesc = txtProjectDescription.Text; string projectcreator = ticket.Name; string grouptoaddname = String.Empty; double percent = 0; string applicationpath = Request.ApplicationPath; string pictureuri = applicationpath + "Images/no_image.png"; List <group> groupquery = new List <group>(); bool is_same_name = false; bool gooduri = Uri.IsWellFormedUriString(txtPictureURI.Text, UriKind.Absolute); if (gooduri == true) { pictureuri = txtPictureURI.Text; } else { lbmessages.Text = "Enter valid absolute url path of the picture"; } if (ddlGroupList.SelectedItem.Text != ddlGroupList.Items[0].Text) { grouptoaddname = ddlGroupList.SelectedItem.Text; groupquery = contentmanager.GetUserGroups(); } DateTime duedate = calendarDueDate.SelectedDate; try { var rightperson = ctx.person.Where(p => p.username == projectcreator).FirstOrDefault(); // Check that the user does not already have a project with the same name List <project> userprojects = contentmanager.GetUserProjects(); foreach (var project in userprojects) { if (project.name == projectname) { is_same_name = true; } } if (is_same_name == false) { // Search the right group given in the dropdownlist if (grouptoaddname != String.Empty) { var rightgroup = ctx.group.Where(g => g.name == grouptoaddname); } int emptyrow = 0; int addedrow = 0; // First check for any gaps in the number sequence inside the database for (int i = 0; i <= ctx.project.Count(); i++) { project compareProject = new project(); var checkProject = ctx.project.Where(gr => gr.project_id == i).FirstOrDefault(); if (checkProject == compareProject) { emptyrow = i; } else { compareProject = checkProject; } } if (emptyrow == 0) { addedrow = ctx.project.Count() + 1; } else { addedrow = emptyrow; } // Insert new project into database var newproject = new project { name = projectname, description = projectdesc, project_creator = rightperson.username, creation_date = DateTime.Now, due_date = duedate, percent_done = percent, finished = false, privacy = 1, picture_url = pictureuri }; var projectlist = ctx.project.ToList(); if (projectlist != null) { int tagindex = 100; foreach (var project in projectlist) { tagindex = (int)project.project_tag + 1; } newproject.project_tag = tagindex; } else { newproject.project_tag = 100; } ctx.project.Add(newproject); ctx.SaveChanges(); return(newproject.project_id); } else { lbmessages.Text = "Error: You already have a project with that name"; return(-1); } } catch (Exception ex) { lbmessages.Text = ex.Message; return(-1); } }
// Method to call when a client connects to the hub and forms a hubproxy public override async Task OnConnected() { try { ctx = new TeeMsEntities(); var connectionlist = ctx.connection.ToList(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); if (connectionlist.Count != 0) { bool makenewconnection = true; foreach (var connection in connectionlist) { if (connection.person_id == rightperson.person_id) { var rightconnection = ctx.connection.Where(con => con.connection_id == connection.connection_id).SingleOrDefault(); rightconnection.connected = true; ctx.SaveChanges(); makenewconnection = false; } } if (makenewconnection == true) { connection newconnection = new connection() { connected = true, connection_username = rightperson.username, person_id = rightperson.person_id }; ctx.connection.Add(newconnection); ctx.SaveChanges(); } } else { connection newconnection = new connection() { connected = true, connection_username = rightperson.username, person_id = rightperson.person_id }; ctx.connection.Add(newconnection); ctx.SaveChanges(); } List <string> grouplist = GetMemberGroups(rightperson); if (grouplist != null) { await JoinGroup(grouplist[0]); GetChatMembers(grouplist[0]); Clients.Client(Context.ConnectionId).changeInitialButton(); } await base.OnConnected(); } catch (Exception ex) { throw ex; } }
protected void UpdateUserProfile() { try { var rightperson = ctx.person.Where(p => p.username == ticket.Name).FirstOrDefault(); var rightlogin = ctx.login.Where(l => l.login_name == ticket.Name).FirstOrDefault(); if (rightperson != null && rightlogin != null) { string uname = rightperson.username; string fname = rightperson.first_name; string lname = rightperson.last_name; string email = rightperson.email; bool ischanged = false; if (txtUserName.Text != String.Empty) { uname = txtUserName.Text; rightperson.username = uname; rightlogin.login_name = uname; ischanged = true; } if (txtFirstName.Text != String.Empty) { fname = txtFirstName.Text; rightperson.first_name = fname; ischanged = true; } if (txtLastName.Text != String.Empty) { lname = txtLastName.Text; rightperson.last_name = lname; ischanged = true; } if (txtEmail.Text != String.Empty) { email = txtEmail.Text; rightperson.email = email; ischanged = true; } if (cbChangeUserPrivacy.Checked == true && rightperson.privacy == 1) { rightperson.privacy = 0; ischanged = true; } if (cbChangeUserPrivacy.Checked == false && rightperson.privacy != 1) { rightperson.privacy = 1; ischanged = true; } if (ischanged == true) { rightperson.edited = DateTime.Now; int num = ctx.SaveChanges(); FormsAuthentication.SetAuthCookie(uname, true); lbErrorMessages.Text = String.Format("Updated {0} database entries", num.ToString()); lbUsernameInsert.Text = uname; lbEmailInsert.Text = email; lbFirstNameInsert.Text = fname; lbLastNameInsert.Text = lname; } else if (ischanged == false) { lbErrorMessages.Text = "Please insert the data you wish to change in the correct textbox"; } } else { lbErrorMessages.Text = "Something went wrong in the database transaction"; } } catch (Exception ex) { lbErrorMessages.Text = ex.Message; } }
protected void CreateNewUser() { // Create a new person and add them to the database string uname = txtUserName.Text; string fname = txtFirstName.Text; string lname = txtLastName.Text; string password = txtPassword.Text; string email = txtEmail.Text; DateTime cdate = DateTime.Now; int privacynro = 1; Encoder encoder = new Encoder(); string salt = encoder.GetSalt(); string saltedhash = encoder.GenerateSaltedHash(password, salt); ctx = new TeeMsEntities(); if (password == txtConfirmPassword.Text) { try { var rightrole = ctx.role.Where(r => r.@class == 3).SingleOrDefault(); int role_to_input = rightrole.role_id; person p = new person { first_name = fname, last_name = lname, username = uname, email = email, creation_date = cdate, privacy = privacynro, role_id = role_to_input }; login l = new login { login_name = uname, salt = salt, password = saltedhash }; connection newconnection = new connection() { connected = false, connection_username = uname, person_id = p.person_id }; ctx.person.Add(p); ctx.login.Add(l); ctx.connection.Add(newconnection); ctx.SaveChanges(); } catch (Exception ex) { lbMessages.Text = ex.Message; if (ex.InnerException != null) { lbMessages.Text = ex.InnerException.ToString(); } } Response.Redirect("Login.aspx"); } }
protected int CreateNewGroup() { ctx = new TeeMsEntities(); try { // First add a new group to the database UserContentManager contentmanager = new UserContentManager(ticket.Name); List <group> usergroupquery = contentmanager.GetUserGroups(); int newgroupnamenro = 1; if (usergroupquery != null) { for (int i = 0; i < usergroupquery.Count; i++) { if (usergroupquery[i].name == String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro)) { newgroupnamenro = newgroupnamenro + 1; i = 0; } } } string newgroupname = String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro); var g = new group { name = newgroupname, creator = ticket.Name, privacy = 1, creation_date = DateTime.Now, }; var grouplist = ctx.group.ToList(); if (grouplist != null) { int tagindex = 100; foreach (var group in grouplist) { tagindex = (int)group.group_tag + 1; } g.group_tag = tagindex; } else { g.group_tag = 100; } ctx.group.Add(g); ctx.SaveChanges(); return(g.group_id); } catch (Exception ex) { lbMessages.Text = ex.Message; return(0); } }
protected int CreateNewAssignment() { string project_textid = Request.QueryString["Project"]; int project_id = int.Parse(project_textid); string name = txtAssignmentName.Text; string description = txtAssignmentDescription.Text; string percent_done = "0"; bool finished = false; DateTime duedate = calendarDueDate.SelectedDate; try { int emptyrow = 0; int addedrow = 0; // First check for any gaps in the number sequence inside the database for (int i = 0; i <= ctx.assignment.Count(); i++) { assignment compareAssignment = new assignment(); var checkAssignment = ctx.assignment.Where(gr => gr.amt_id == i).FirstOrDefault(); if (checkAssignment == compareAssignment) { emptyrow = i; } else { compareAssignment = checkAssignment; } } if (emptyrow == 0) { addedrow = ctx.assignment.Count() + 1; } else { addedrow = emptyrow; } var newassignment = new assignment { name = name, description = description, creation_date = DateTime.Today, assignment_due_date = duedate, percent_done = percent_done, finished = finished, privacy = 1, project_id = project_id }; var assignmentlist = ctx.assignment.ToList(); if (assignmentlist != null) { int tagindex = 100; foreach (var assignment in assignmentlist) { tagindex = (int)assignment.amt_tag + 1; } newassignment.amt_tag = tagindex; } else { newassignment.amt_tag = 100; } ctx.assignment.Add(newassignment); ctx.SaveChanges(); return(newassignment.amt_id); } catch (Exception ex) { if (ex.InnerException != null) { lbmessages.Text = ex.InnerException.ToString(); } else { lbmessages.Text = ex.Message; } return(-1); } }
protected int CreateNewGroup() { ctx = new TeeMsEntities(); int emptyrow = 0; int addedrow = 0; // First check for any gaps in the number sequence inside the database for (int i = 0; i <= ctx.group.Count(); i++) { group compareGroup = new group(); var checkGroup = ctx.group.Where(gr => gr.group_tag == i).SingleOrDefault(); if (checkGroup == compareGroup) { emptyrow = i; } else { compareGroup = checkGroup; } } if (emptyrow == 0) { addedrow = ctx.group.Count() + 1; } else { addedrow = emptyrow; } // Next add a new group to the database try { UserContentManager contentmanager = new UserContentManager(ticket.Name); List <group> usergroupquery = contentmanager.GetUserGroups(); int newgroupnamenro = 1; if (usergroupquery != null) { for (int i = 0; i < usergroupquery.Count; i++) { if (usergroupquery[i].name == String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro)) { newgroupnamenro = newgroupnamenro + 1; i = 0; } } } string newgroupname = String.Format("New Group {0}", usergroupquery.Count + newgroupnamenro); var g = new group { name = newgroupname, group_tag = addedrow, creator = ticket.Name, privacy = 1, creation_date = DateTime.Now, }; ctx.group.Add(g); ctx.SaveChanges(); return(g.group_id); } catch (Exception ex) { lbMessages.Text = ex.Message; return(0); } }
// Method to call when a client connects to the hub and forms a hubproxy public override async Task OnConnected() { try { ctx = new TeeMsEntities(); int project_id = int.Parse(this.Context.QueryString["Project"]); string assignment_textid = String.Empty; if (this.Context.QueryString["Assignment"] != null) { assignment_textid = this.Context.QueryString["Assignment"]; } var connectionlist = ctx.connection.ToList(); var rightperson = ctx.person.Where(p => p.username == Context.User.Identity.Name).SingleOrDefault(); var rightproject = ctx.project.Where(pr => pr.project_id == project_id).SingleOrDefault(); foreach (var connection in connectionlist) { if (connection.person_id == rightperson.person_id) { var rightconnection = ctx.connection.Where(con => con.connection_id == connection.connection_id).SingleOrDefault(); rightconnection.connected = true; ctx.SaveChanges(); } } var projectconnection = rightperson.project_person.Where(prope => prope.project_id == rightproject.project_id).SingleOrDefault(); if (projectconnection != null) { await JoinGroup(rightproject.name + rightproject.project_id.ToString()); } if (rightproject.name != String.Empty) { SendProjectName(rightproject); } if (rightproject.picture_url != String.Empty) { SendProjectImage(rightproject); } if (assignment_textid != String.Empty) { int assignment_id = int.Parse(assignment_textid); var rightassignment = ctx.assignment.Where(amt => amt.amt_id == assignment_id).SingleOrDefault(); SendAssignmentDescription(rightproject, rightassignment); Clients.OthersInGroup(rightproject.name + rightproject.project_id.ToString()).updateAssignmentProgress(); } else { SendProjectDescription(rightproject); } await base.OnConnected(); } catch (Exception ex) { throw ex; } }