public string Backup(int asstID) { string zfile, wzfile; Assignment asst = GetInfo(asstID); //Check permission Authorize(asst.CourseID, "createbackup", asstID, null); //Create our external sink file IExternalSink extsink = ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink; zfile = Globals.PurifyString(asst.Description)+ DateTime.Now.Hour+DateTime.Now.Minute+DateTime.Now.Second+".zip"; wzfile = Globals.BackupDirectoryName + "/" + zfile; zfile = Path.Combine(Globals.BackupDirectory, zfile); extsink.CreateSink(zfile); //Backup Info //Backup Results //Back up submissions Users users = new Users(m_ident); User.UserList mems = new Courses(m_ident).GetMembers(asst.CourseID, null); foreach (User mem in mems) users.Backup(mem.UserName, asst.CourseID, asstID, extsink); extsink.CloseSink(); new Backups(m_ident).Create(asst.Description, wzfile, asst.CourseID); return zfile; }
public string Backup(int courseID) { string zfile, wzfile; Authorize(courseID, Permission.COURSE, "createback", courseID, null); //Create our external sink file IExternalSink extsink = ArchiveToolFactory.GetInstance().CreateArchiveTool(".zip") as IExternalSink; Course course = GetInfo(courseID); zfile = course.Name+DateTime.Now.Hour+DateTime.Now.Minute+DateTime.Now.Second+".zip"; wzfile = Globals.BackupDirectoryName + "/" + zfile; zfile = Path.Combine(Globals.BackupDirectory, zfile); extsink.CreateSink(zfile); //Backup Info //Backup Results //Back up submissions Users users = new Users(m_ident); User.UserList mems = GetMembers(courseID, null); foreach (User mem in mems) users.Backup(mem.UserName, courseID, extsink); extsink.CloseSink(); //Log in database new Backups(m_ident).Create(GetInfo(courseID).Name, wzfile, courseID); return zfile; }
private void BindData() { Users userda = new Users(Globals.CurrentIdentity); Courses courseda = new Courses(Globals.CurrentIdentity); int courseID = GetCourseID(); User user = userda.GetInfo(GetUsername(), null); txtFirst.Text = user.FirstName; txtLast.Text = user.LastName; txtEmail.Text = user.Email; double total = courseda.GetTotalPoints(courseID); double userp = userda.GetCoursePoints(user.UserName, courseID); lblTotal.Text = String.Format("{0} / {1} ({2}%)", userp, total, Math.Round((userp/total)*100.0, 2)); dgReport.DataSource = courseda.GetAssignments(courseID); dgReport.DataBind(); CourseRole.CourseRoleList roles = courseda.GetRoles(courseID, null); CourseRole urole = courseda.GetRole(user.UserName, courseID, null); ddlRoles.Items.Clear(); foreach (CourseRole role in roles) { ListItem item = new ListItem(role.Name, role.PrincipalID.ToString()); if (role.PrincipalID == urole.PrincipalID) item.Selected = true; ddlRoles.Items.Add(item); } }
private void BindInviteGrid() { int asstID = GetAsstID(); Invitation.InvitationList invites = new Users(Globals.CurrentIdentity).GetInvitations(Globals.CurrentUserName, asstID); dgInvitations.DataSource = invites; dgInvitations.DataBind(); }
private void BindData() { User curuser = new Users(Globals.CurrentIdentity).GetInfo(Globals.CurrentUserName, null); lblUserName.Text = "Username: <b>" + curuser.UserName + "</b>"; txtFirst.Text = curuser.FirstName; txtLast.Text = curuser.LastName; txtEmail.Text = curuser.Email; }
private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { User curuser = new Users(Globals.CurrentIdentity).GetInfo(Globals.CurrentUserName, null); lblName.Text = curuser.FirstName + " " + curuser.LastName + "!"; if (curuser.Admin) divAdmin.Visible = true; else divAdmin.Visible = false; } }
protected string GetAsstPoints(User user, int asstID) { Components.Submission latsub = new Principals(Globals.CurrentIdentity).GetLatestGradedSubmission(user.PrincipalID, asstID); double total = new Assignments(Globals.CurrentIdentity).GetRubric(asstID).Points; if (latsub != null) { double userp = new Users(Globals.CurrentIdentity).GetAsstPoints(user.UserName, asstID); return String.Format("{0} / {1} ({2}%)", userp, total, Math.Round((userp/total)*100.0, 2)); } else return String.Format("?? / {0}", total); }
public bool SendByPrincipal(int principalID, string subj, string body) { Principal prin = new Principals(m_ident).GetInfo(principalID); if (prin.Type == Principal.USER) { User user = new Users(m_ident).GetInfo(prin.Name, null); return SendByEmail(user.Email, subj, body); } else { User.UserList users = new Groups(m_ident).GetMembership(principalID); foreach (User user in users) SendByEmail(user.Email, subj, body); } return true; }
private void BindFileLink() { string roots=""; //Check to see if we already did this, if not then calculate sub root string for FB if (!GetFileRoots(out roots)) { Users userda = new Users(Globals.CurrentIdentity); User.UserList users = CourseMatrixControl.GetFeedbackUsers(GetUserList()); foreach (User user in users) { Components.Submission.SubmissionList subs = userda.GetAsstSubmissions(user.UserName, GetAsstID()); foreach (Components.Submission sub in subs) roots += sub.LocationID.ToString() + "|"; } ViewState["fileroots"] = roots; } lnkLoadAll.Attributes.Add("onClick", @"window.open('filebrowser.aspx?Roots=" + roots + @"', '"+8+@"', 'width=730, height=630')"); }
private void cmdLogin_Click(object sender, System.EventArgs e) { Users userda = new Users(Globals.CurrentIdentity); if (userda.IsValid(txtUsername.Text, txtPassword.Text)) { User user = userda.GetInfo(txtUsername.Text, null); if (user.VerifyKey != "" && txtVerifyKey.Text == "") { PageError("You must activate your account now. Enter the verification key found in the FrontDesk activiation email and enter it into the Verify Key box and log in again."); lblVerifyKey.Visible = true; txtVerifyKey.Visible = true; } else { if (user.VerifyKey != txtVerifyKey.Text) PageError("Incorrect verification key, please check the email to make sure you typed it in correctly"); else { // if set to false, you have to login each time FormsAuthentication.SetAuthCookie(txtUsername.Text, true); string redirectUrl = Page.Request.QueryString["ReturnUrl"]; // Update verification key to "" user.VerifyKey = ""; userda.Update(user, null); if (redirectUrl != null) { Page.Response.Redirect(redirectUrl); Page.Response.End(); } else { Page.Response.Redirect(Globals.DefaultUrl); Page.Response.End(); } } } } else PageError("Username or password are incorrect. Try again, or if you have not registered, click the Register tab above to obtain an account."); txtVerifyKey.Text = ""; }
private void BindUserItem(CourseMember mem, Label lblName, Label lblProgress, System.Web.UI.WebControls.Image imgStatus, System.Web.UI.WebControls.Image imgType, CheckBox chkSelect) { User user = mem.User; imgType.ImageUrl = "../../attributes/user.gif"; lblName.Text = user.FullName + "(" + user.UserName + ")"; Users userda = new Users(Globals.CurrentIdentity); Components.Submission sub = userda.GetLatestAsstSubmission(user.UserName, GetAsstID()); if (sub == null) { imgStatus.ImageUrl = "../../attributes/nosub.gif"; lblProgress.Text = "N/A"; chkSelect.Enabled = false; } else { switch (sub.Status) { case Components.Submission.GRADED: imgStatus.ImageUrl = "../../attributes/subgrade.gif"; lblProgress.Text = "100%"; break; case Components.Submission.INPROGRESS: imgStatus.ImageUrl = "../../attributes/clock.gif"; lblProgress.Text = "??%"; break; case Components.Submission.UNGRADED: imgStatus.ImageUrl = "../../attributes/sub.gif"; lblProgress.Text = "0%"; break; } } }
private string HarvestSelectedUsers() { string userstr=""; Label lblType, lblID; Sections sectda = new Sections(Globals.CurrentIdentity); Users userda = new Users(Globals.CurrentIdentity); foreach (DataGridItem row in dgUsers.Items) { if ((row.FindControl("chkSelect") as CheckBox).Checked) { lblType = (Label) row.FindControl("lblType"); lblID = (Label) row.FindControl("lblID"); string sid = lblID.Text; if (lblType.Text == "S") { int id = Convert.ToInt32(sid); User.UserList users = sectda.GetMembers(id); foreach (User user in users) userstr += user.UserName + "|"; } else userstr += sid + "|"; } } return userstr; }
private int GetSectionProgress(Section sec) { Users userda = new Users(Globals.CurrentIdentity); User.UserList users = new Sections(Globals.CurrentIdentity).GetMembers(sec.ID); int done=0, count=0; foreach (User user in users) { Components.Submission sub = userda.GetLatestAsstSubmission(user.UserName, GetAsstID()); if (sub != null) { count++; if (sub.Status == Components.Submission.GRADED) done++; } } return Math.Min(100, Math.Max(0, (int)(((double)done)/((double)count)*100.0))); }
protected void BindUsers() { User.UserList users = new Users(Globals.CurrentIdentity).GetAll(); lstInstructor.Items.Clear(); foreach (User user in users) lstInstructor.Items.Add( new ListItem(user.FullName + " (" + user.UserName + ")", user.UserName)); }
/// <summary> /// Create a set of users specified by XML data /// </summary> public void BatchCreate(Stream xmlStream, bool sync) { User user = new User(); Users userDB = new Users(Globals.CurrentIdentity); DataSet xmldata = new DataSet(); xmldata.ReadXml(xmlStream); DataRowCollection users = xmldata.Tables["User"].Rows; IProviderTransaction tran = m_dp.BeginTransaction(); foreach (DataRow row in users) { user.UserName = (string) row["UserName"]; user.FirstName = (string) row["FirstName"]; user.LastName = (string) row["LastName"]; user.Email = (string) row["Email"]; //If the user is already in the system if (null != userDB.GetInfo(user.UserName, tran)) { if (sync) m_dp.UpdateUser(user, tran); else { m_dp.RollbackTransaction(tran); throw new DataAccessException("User: "******" is already in the FrontDesk database. Use a merge to add additional users."); } } else { string passwd = Globals.GeneratePassword(Globals.MinPasswordLength); m_dp.CreateUser(user, passwd, tran); new EmailWizard(m_ident).SendByUsername(user.UserName, "FrontDesk: User Account Created", String.Format(Globals.GetMessage("CreateUser"), user.UserName, passwd, user.Email)); } } m_dp.CommitTransaction(tran); }
private void dgReport_ItemDataBound(object sender, DataGridItemEventArgs e) { Label lblPoints; if (null != (lblPoints = (Label) e.Item.FindControl("lblPoints"))) { int asstID = Convert.ToInt32(dgReport.DataKeys[e.Item.ItemIndex]); User user = new Users(Globals.CurrentIdentity).GetInfo(GetUsername(), null); Components.Submission latsub = new Principals(Globals.CurrentIdentity).GetLatestGradedSubmission(user.PrincipalID, asstID); double total = new Assignments(Globals.CurrentIdentity).GetRubric(asstID).Points; if (latsub != null) { double userp = new Users(Globals.CurrentIdentity).GetAsstPoints(user.UserName, asstID); lblPoints.Text = String.Format("{0} / {1} ({2}%)", userp, total, Math.Round((userp/total)*100.0, 2)); } else { lblPoints.Text = String.Format("?? / {0}", total); } } }
private void cmdExport_Click(object sender, System.EventArgs e) { CFile export; ExportRow.ExportRowList rows = new ExportRow.ExportRowList(); int courseID = GetCourseID(); Users userda = new Users(Globals.CurrentIdentity); User.UserList users = GetUserSet(GetSectionID(), GetCourseID()); //Add rows rows.Add(userda.GetCourseExportHeading(courseID)); foreach (User user in users) rows.Add(userda.GetCourseExport(user.UserName, courseID)); //Do export try { IExporter exporter = (IExporter) ExporterFactory.GetInstance().CreateItem(ddlExportFormat.SelectedItem.Value); export = exporter.Export(new FileSystem(Globals.CurrentIdentity), rows); } catch (CustomException er) { PageExportError(er.Message); return; } //Setup d/l link lnkExport.Attributes.Clear(); lnkExport.Attributes.Add("onClick", @"window.open('Controls/Filesys/dlfile.aspx?FileID=" + export.ID + @"', '"+export.ID+@"', 'width=770, height=580')"); lnkExport.Visible = true; }
private void dgReport_ItemDataBound(object sender, DataGridItemEventArgs e) { Label lblPoints; if (null != (lblPoints = (Label) e.Item.FindControl("lblPoints"))) { int asstID = Convert.ToInt32(dgReport.DataKeys[e.Item.ItemIndex]); User user = new Users(Globals.CurrentIdentity).GetInfo(GetUsername(), null); lblPoints.Text = GetAsstPoints(user, asstID); } }
private void dgCourse_ItemDataBound(object sender, DataGridItemEventArgs e) { Label lblStudent, lblPoints; if (null != (lblStudent = (Label) e.Item.FindControl("lblStudent"))) { lblPoints = (Label) e.Item.FindControl("lblPoints"); User user = e.Item.DataItem as User; int courseID = GetCourseID(); double total = new Courses(Globals.CurrentIdentity).GetTotalPoints(courseID); double userp = new Users(Globals.CurrentIdentity).GetCoursePoints(user.UserName, courseID); lblPoints.Text = String.Format("{0} / {1} ({2}%)", userp, total, Math.Round((userp/total)*100.0, 2)); lblStudent.Text = user.FullName + " (" + user.UserName + ")"; } }
private void BindMemberGrid() { int asstID = GetAsstID(); Group.GroupList groups = new Users(Globals.CurrentIdentity).GetGroups(Globals.CurrentUserName, asstID); dgMemberships.DataSource = groups; dgMemberships.DataBind(); }
private void BindSubs() { int asstID = Convert.ToInt32(Request.Params["AsstID"]); Components.Submission.SubmissionList subs = new Users(Globals.CurrentIdentity).GetAsstSubmissions(Globals.CurrentUserName, asstID); ddlSubs.Items.Clear(); foreach (Components.Submission sub in subs) { string name = new Principals(Globals.CurrentIdentity).GetInfo(sub.PrincipalID).Name + " (" + sub.Creation.ToString() + ")"; ddlSubs.Items.Add(new ListItem(name, sub.ID.ToString())); } }
public static User.UserList GetFeedbackUsers(string userstr) { string [] spids = userstr.Split("|".ToCharArray()); Users userda = new Users(Globals.CurrentIdentity); User.UserList users = new User.UserList(); foreach (string spid in spids) if (spid.Length > 0) users.Add(userda.GetInfo(spid, null)); return users; }
/// <summary> /// Remove a user from a course /// </summary> public bool RemoveUser(string user, int courseID) { //Kill all submissions Submissions subda = new Submissions(m_ident); Components.Submission.SubmissionList subs = new Users(m_ident).GetCourseSubmissions(user, courseID); foreach (Components.Submission sub in subs) subda.Delete(sub.ID); return m_dp.DeleteCourseMember(user, courseID); }
/// <summary> /// Deny a permission to an entity /// </summary> public bool Deny(string username, string etype, string perm, int entityID, int courseID) { Authorize(courseID, etype, "updateperms", entityID, null); User user = new Users(m_ident).GetInfo(username, null); return m_dp.DenyPermission(user.PrincipalID, perm, etype, entityID); }
/// <summary> /// Add users to the course from an XML stream /// </summary> public void BatchAddUsers(Stream xmlStream, int courseID, bool sync) { //TODO: Error checking User mem = new User(); Users usersDB = new Users(m_ident); DataSet xmldata = new DataSet(); xmldata.ReadXml(xmlStream); DataRowCollection users = xmldata.Tables["User"].Rows; IProviderTransaction tran = m_dp.BeginTransaction(); foreach (DataRow row in users) { mem.UserName = (string) row["UserName"]; string role = (string) row["Role"]; //Make sure the user is in the system if (null == usersDB.GetInfo(mem.UserName, tran)) { m_dp.RollbackTransaction(tran); throw new DataAccessException("User: "******" is not in the FrontDesk database"); } User.UserList cmems = GetMembers(courseID, tran); //The user already exists in the course if (cmems.Contains(mem)) { if (sync) UpdateRole(mem.UserName, courseID, role, tran); else { m_dp.RollbackTransaction(tran); throw new DataAccessException("User: "******" already exists in the course. " + "Do a merge if you want to change the roles"); } } else m_dp.CreateCourseMember(mem.UserName, courseID, role, tran); } m_dp.CommitTransaction(tran); }
public bool SendByUsername(string username, string subj, string body) { User user = new Users(m_ident).GetInfo(username, null); return SendByEmail(user.Email, subj, body); }
private string[] HarvestSelectedUsers(System.Web.UI.WebControls.DataGrid sgrid) { string userstr="", prinstr=""; Label lblType, lblID; Sections sectda = new Sections(Globals.CurrentIdentity); Users userda = new Users(Globals.CurrentIdentity); foreach (DataGridItem row in sgrid.Items) { if ((row.FindControl("chkSelect") as CheckBox).Checked) { lblType = (Label) row.FindControl("lblType"); lblID = (Label) row.FindControl("lblID"); string sid = lblID.Text; if (lblType.Text == "S") { int id = Convert.ToInt32(sid); User.UserList users = sectda.GetMembers(id); foreach (User user in users) { userstr += user.UserName + "|"; prinstr += user.PrincipalID.ToString() + " "; } } else { userstr += sid + "|"; User user = userda.GetInfo(sid, null); prinstr += user.PrincipalID.ToString() + " "; } } } string[] retarr = new string[2]; retarr[0] = userstr; retarr[1] = prinstr; return retarr; }
private void tvSection_Check(object sender, TreeViewClickEventArgs e) { TreeNode node = tvSection.GetNodeFromIndex(e.Node); Users users = new Users(Globals.CurrentIdentity); int courseID = Convert.ToInt32(HttpContext.Current.Request.Params["CourseID"]); string[] tokens; if (node.NodeData.IndexOf("Uname") == 0) { tokens = node.NodeData.Split(" ".ToCharArray()); int pid = users.GetInfo(tokens[1], null).PrincipalID; ArrayList prins = Principals; if (node.Checked) prins.Add(pid); else prins.Remove(pid); Principals = prins; } else if (node.NodeData.IndexOf("Group") == 0) { tokens = node.NodeData.Split(" ".ToCharArray()); int pid = Convert.ToInt32(tokens[1]); ArrayList prins = Principals; if (node.Checked) prins.Add(pid); else prins.Remove(pid); Principals = prins; } else if (node.NodeData.IndexOf("Uallusers") == 0) { User.UserList mems = new Courses(Globals.CurrentIdentity).GetMembers(courseID, null); ArrayList prins = Principals; foreach (TreeNode cnode in node.Nodes) cnode.Checked = node.Checked; foreach (User mem in mems) { if (node.Checked) prins.Add(mem.PrincipalID); else prins.Remove(mem.PrincipalID); } node.Expanded = true; Principals = prins; } else if (node.NodeData.IndexOf("Section") == 0) { tokens = node.NodeData.Split(" ".ToCharArray()); User.UserList susers = (new Sections(Globals.CurrentIdentity)).GetMembers( Convert.ToInt32(tokens[1])); if (node.Nodes.Count == 0) AddSectionMembers(node); foreach (TreeNode cnode in node.Nodes) cnode.Checked = node.Checked; ArrayList prins = Principals; foreach (User user in susers) { if (node.Checked) prins.Add(user.PrincipalID); else prins.Remove(user.PrincipalID); } node.Expanded = true; Principals = prins; } }
private void SetupBrowser(int asstID) { FileSystem fs = new FileSystem(Globals.CurrentIdentity); Components.Submission.SubmissionList subdata = new Users(Globals.CurrentIdentity).GetAsstSubmissions(Globals.CurrentUserName, asstID); string roots=""; foreach (Components.Submission sub in subdata) roots += sub.LocationID + "|"; lnkFiles.Attributes.Clear(); lnkFiles.Attributes.Add("onClick", @"window.open('filebrowser.aspx?Roots=" + roots + @"', '"+8+@"', 'width=730, height=630')"); }
private void LoadUserNode(TreeNode par, string username, int asstID) { Components.Submission.SubmissionList subs = new Users(Globals.CurrentIdentity).GetAsstSubmissions(username, asstID); par.Nodes.Clear(); foreach (Components.Submission sub in subs) AddUserSubNode(par.Nodes, username, sub); }