private static CourseM LoadCourseFromDatabase(DatabaseCall dbc) { CourseM newCourse = new CourseM(); System.Data.DataSet ds = new System.Data.DataSet(); dbc.Fill(ds); if ((ds.Tables.Count <= 0) || (ds.Tables[0].Rows.Count <= 0)) { return(newCourse); } newCourse._courseID = Convert.ToInt32(ds.Tables[0].Rows[0]["CourseID"]); newCourse._courseGUID = new System.Guid(ds.Tables[0].Rows[0]["CourseGUID"].ToString()); newCourse.Name = ds.Tables[0].Rows[0]["ShortName"].ToString(); newCourse.Description = ds.Tables[0].Rows[0]["Description"].ToString(); newCourse.LastUpdatedDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["LastUpdatedDate"]); newCourse.LastUpdatedUserID = Convert.ToInt32(ds.Tables[0].Rows[0]["LastUpdatedUserID"]); newCourse.HomepageURL = ds.Tables[0].Rows[0]["HomepageURL"].ToString(); newCourse.SendEmailRemindersFlag = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendEmailRemindersFlag"]); newCourse.StartDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["StartDate"]); newCourse.EndDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["EndDate"]); newCourse.RootStoragePath = ds.Tables[0].Rows[0]["RootStoragePath"].ToString(); return(newCourse); }
private static UserM LoadUserFromDatabase(DatabaseCall dbc) { UserM newUser = new UserM(); System.Data.DataSet ds = new System.Data.DataSet(); dbc.Fill(ds); if ((ds.Tables.Count <= 0) || (ds.Tables[0].Rows.Count <= 0)) { return(newUser); } newUser._userID = Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]); newUser._lastName = ds.Tables[0].Rows[0]["LastName"].ToString(); newUser._middleName = ds.Tables[0].Rows[0]["MiddleName"].ToString(); newUser._firstName = ds.Tables[0].Rows[0]["FirstName"].ToString(); newUser._emailAddress = ds.Tables[0].Rows[0]["Email"].ToString(); newUser._universityID = ds.Tables[0].Rows[0]["UniversityIdentifier"].ToString(); newUser._username = ds.Tables[0].Rows[0]["UserName"].ToString(); newUser._password = ds.Tables[0].Rows[0]["Password"].ToString(); newUser._lastUpdatedDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["LastUpdatedDate"].ToString()); newUser._lastUpdatedUserID = Convert.ToInt32(ds.Tables[0].Rows[0]["LastUpdatedUserID"]); newUser._changedPassword = Convert.ToBoolean(ds.Tables[0].Rows[0]["ChangedPassword"]); return(newUser); }
internal static bool CommitImport(string importID) { DatabaseCall dbc = new DatabaseCall("Import_LoadPendingImport", DBCallType.Select); dbc.AddParameter("@ImportID", importID); System.Data.DataSet ds = new System.Data.DataSet(); dbc.Fill(ds); if ((ds.Tables.Count <= 0) || (ds.Tables[0].Rows.Count <= 0)) { return(false); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { try { UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"])); user.GenerateNewPassword(); user.AddToCourse(Convert.ToInt32(ds.Tables[0].Rows[i]["CourseID"])); } catch { } } return(true); }
public static RoleM[] GetAllRoles() { DatabaseCall dbc = new DatabaseCall("Roles_BrowseAll", DBCallType.Select); System.Data.DataSet ds = new System.Data.DataSet(); dbc.Fill(ds); if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return(new RoleM[0]); } else { RoleM[] roles = new RoleM[(ds.Tables[0].Rows.Count)]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int roleID = Convert.ToInt32(ds.Tables[0].Rows[i]["RoleID"]); string roleName = ds.Tables[0].Rows[i]["Name"].ToString(); // replace with localized name if available string localizedName = SharedSupport.GetLocalizedString("UserRole_" + roleName); if (localizedName != String.Empty) { roleName = localizedName; } roles[i] = new RoleM(roleID, roleName); } return(roles); } }
public string StarterFilesXML(System.Guid guid) { try { DataSet ds = new DataSet(); string downloadRoot = SharedSupport.AddBackSlashToDirectory(System.Web.HttpContext.Current.Request.MapPath(String.Empty, Constants.ASSIGNMENTMANAGER_DOWNLOAD_DIRECTORY, true)); string storageLocation = String.Empty; AssignmentM assign = AssignmentM.Load(_assignmentID); storageLocation = SharedSupport.AddBackSlashToDirectory(assign.StorageDirectory + Constants.STARTER_PROJECT_PATH); //add unique guid to download path downloadRoot = downloadRoot + SharedSupport.AddBackSlashToDirectory(guid.ToString()); DatabaseCall dbc = new DatabaseCall("Assignments_GetFiles", DBCallType.Select); dbc.AddParameter("@AssignmentID", _assignmentID); dbc.Fill(ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string source = String.Empty; string destination = String.Empty; string filename = ds.Tables[0].Rows[i]["FileName"].ToString().Trim(); filename = filename.Replace(@"\", @"/"); source = SharedSupport.RemoveIllegalFilePathCharacters(storageLocation + filename); destination = SharedSupport.RemoveIllegalFilePathCharacters(downloadRoot + filename); //check to see if destination directory exists string destinationDir = destination.Substring(0, destination.LastIndexOf("\\") + 1); if (!Directory.Exists(destinationDir)) { Directory.CreateDirectory(destinationDir); } //check if file is there if (System.IO.File.Exists(source)) { System.IO.File.Copy(source, destination, true); } else { throw new System.IO.FileNotFoundException(SharedSupport.GetLocalizedString("Assignment_UploadedFileNotFound")); } if (filename.StartsWith(@"/")) { ds.Tables[0].Rows[i]["FileName"] = guid + filename; } else { ds.Tables[0].Rows[i]["FileName"] = guid + @"/" + filename; } } return(ds.GetXml()); } catch (Exception e) { return(e.Message); } }
public static AssignmentList GetSubmissionsForAssignment(int AssignmentID) { DatabaseCall dbc = new DatabaseCall("Courses_GetSubmissionsList", DBCallType.Select); AssignmentList assignList = new AssignmentList(); dbc.AddParameter("@AssignmentID", AssignmentID); dbc.Fill(assignList.assignmentDS); return(assignList); }
public static UserList GetListFromCourse(int courseID) { UserList userList = new UserList(); DatabaseCall dbc = new DatabaseCall("Courses_GetUserList", DBCallType.Select); dbc.AddParameter("@CourseID", courseID); dbc.Fill(userList.ds); return(userList); }
public static AssignmentList GetAssignmentListNotInCourse(int CourseID) { //**** DatabaseCall dbc = new DatabaseCall("Courses_GetAssignmentListNotInCourse", DBCallType.Select); AssignmentList assignList = new AssignmentList(); dbc.AddParameter("@CourseID", CourseID); dbc.Fill(assignList.assignmentDS); return(assignList); }
public static StudentAssignmentM Load(int userAssignmentID) { System.Data.DataSet ds = new System.Data.DataSet(); DatabaseCall dbc = new DatabaseCall("StudentAssignments_LoadAssignmentByUserAssignmentID", DBCallType.Select); dbc.AddParameter("@UserAssignmentID", userAssignmentID); dbc.Fill(ds); if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) { return(null); } return(PopulateNewAssignment(ds)); }
internal static AssignmentM Load(int assignmentID) { //set courseID = 0, it will get overwritten when we load. AssignmentM retVal = new AssignmentM(0); DatabaseCall dbc = new DatabaseCall("Assignments_LoadAssignment", DBCallType.Select); dbc.AddParameter("@AssignmentID", assignmentID); DataSet ds = new DataSet(); dbc.Fill(ds); if (ds.Tables.Count <= 0) { return(null); } // Populate the return value. retVal._assignmentID = assignmentID; retVal.Description = ds.Tables[0].Rows[0]["Description"].ToString(); retVal.StarterProjectFlag = Convert.ToBoolean(ds.Tables[0].Rows[0]["StarterProjectFlag"]); retVal.ShortName = ds.Tables[0].Rows[0]["ShortName"].ToString(); retVal.CompilerType = ds.Tables[0].Rows[0]["CompilerType"].ToString(); retVal.LastUpdatedDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["LastUpdatedDate"].ToString()); retVal.LastUpdatedUserID = Convert.ToInt32(ds.Tables[0].Rows[0]["LastUpdatedUserID"]); retVal.DueDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["DueDate"].ToString()); retVal.AssignmentURL = ds.Tables[0].Rows[0]["AssignmentURL"].ToString(); retVal.CommandLineArgs = ds.Tables[0].Rows[0]["CommandLineArgs"].ToString(); retVal.InputFile = ds.Tables[0].Rows[0]["InputFile"].ToString(); retVal.OutputFile = ds.Tables[0].Rows[0]["OutputFile"].ToString(); retVal.MultipleSubmitsFlag = Convert.ToBoolean(ds.Tables[0].Rows[0]["MultipleSubmitsFlag"]); retVal.AutoGradeFlag = Convert.ToBoolean(ds.Tables[0].Rows[0]["AutoGradeFlag"]); retVal.AutoCompileFlag = Convert.ToBoolean(ds.Tables[0].Rows[0]["AutoCompileFlag"]); retVal.SendReminders = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendReminders"]); retVal.SendPastDue = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendPastDue"]); retVal.SendNewProject = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendNewProject"]); retVal.SendUpdatedProject = Convert.ToBoolean(ds.Tables[0].Rows[0]["SendUpdatedProject"]); retVal.GradeType = Convert.ToByte(ds.Tables[0].Rows[0]["GradeType"]); retVal.CourseAssignmentID = Convert.ToInt32(ds.Tables[0].Rows[0]["CourseAssignmentID"]); retVal.ReminderWarningDays = Convert.ToInt32(ds.Tables[0].Rows[0]["ReminderWarningDays"]); retVal.PastDueWarningDays = Convert.ToInt32(ds.Tables[0].Rows[0]["PastDueWarningDays"]); retVal.CourseID = Convert.ToInt32(ds.Tables[0].Rows[0]["CourseID"]); return(retVal); }
public static RoleM GetUsersRoleInCourse(int userID, int courseID) { DatabaseCall dbc = new DatabaseCall("Roles_GetRoleForUserInCourse", DBCallType.Select); dbc.AddParameter("@UserID", userID); dbc.AddParameter("@CourseID", courseID); System.Data.DataSet ds = new System.Data.DataSet(); dbc.Fill(ds); if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return(new RoleM(0, "")); } else { int roleID = Convert.ToInt32(ds.Tables[0].Rows[0]["RoleID"]); string roleName = ds.Tables[0].Rows[0]["Name"].ToString(); return(new RoleM(roleID, roleName)); } }
internal static bool SecurityIsAllowed(int userID, int courseID, SecurityAction action) { DatabaseCall dbc = new DatabaseCall("Security_IsAllowed", DBCallType.Select); dbc.AddParameter("@UserID", userID); dbc.AddParameter("@CourseID", courseID); dbc.AddParameter("@ActionID", (int)action); System.Data.DataSet ds = new System.Data.DataSet(); dbc.Fill(ds); try { if (Convert.ToInt32(ds.Tables[0].Rows[0]["UserID"]) == userID) { return(true); } } catch { return(false); } return(false); }
/// <summary> /// Retrieves value from Settings table /// </summary> /// <param name="settingName"> </param> internal static string GetSetting(string settingName) { try { // validate parameter if (settingName == null || settingName == String.Empty) { throw new ArgumentNullException(SharedSupport.GetLocalizedString("SharedSupport_SettingNameField"), SharedSupport.GetLocalizedString("SharedSupport_Missing_SettingName")); } if (settingName.Equals(Constants.AUTOBUILD_SETTING) || settingName.Equals(Constants.AUTOCHECK_SETTING)) { // query the status of the actual service return(getServiceStatus(Constants.ACTION_SERVICE_NAME)); } else { DatabaseCall dbc = new DatabaseCall("Settings_GetSetting", DBCallType.Select); dbc.AddParameter("@Setting", settingName); System.Data.DataSet ds = new System.Data.DataSet(); dbc.Fill(ds); try { string returnval = ds.Tables[0].Rows[0]["Value"].ToString().Trim(); return(returnval); } catch { return(String.Empty); } } } catch (System.Exception e) { SharedSupport.HandleError(e); return(null); } }