示例#1
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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)
            {
                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);
        }
示例#6
0
        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));
            }
        }
        /// <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
                    {
                        return(ds.Tables[0].Rows[0]["Value"].ToString().Trim());
                    }
                    catch
                    {
                        return(String.Empty);
                    }
                }
            }
            catch (System.Exception e)
            {
                SharedSupport.HandleError(e);
                return(null);
            }
        }
示例#8
0
        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();
                    roles[i] = new RoleM(roleID, roleName);
                }
                return(roles);
            }
        }
        public void SendNotifications(object sender, System.Timers.ElapsedEventArgs args)
        {
            // disable the timer
            timer.Enabled = false;

            try
            {
                // use Assignment Manager sysadmin email
                UserM  amsaUser    = UserM.Load(Constants.ASSIGNMENTMANAGER_SYSTEM_ADMIN_USERID);
                string sentByEmail = amsaUser.EmailAddress;

                System.Data.DataSet dsAssignmentList = new System.Data.DataSet();
                DatabaseCall        dbc = new DatabaseCall("Notifications_GetAssignmentList", DBCallType.Select);
                dbc.Fill(dsAssignmentList);
                if (dsAssignmentList.Tables[0].Rows.Count <= 0)
                {
                    return;
                }

                for (int j = 0; j < dsAssignmentList.Tables[0].Rows.Count; j++)
                {
                    int assignmentID = Convert.ToInt32(dsAssignmentList.Tables[0].Rows[j]["AssignmentID"]);
                    // send the notifications
                    try
                    {
                        //////////////////////////////////////////////////////////////////////
                        /// Past Due Notifications
                        //////////////////////////////////////////////////////////////////////
                        System.Data.DataSet ds = new System.Data.DataSet();
                        dbc = new DatabaseCall("Notifications_BrowsePastDueNotifications", DBCallType.Select);
                        dbc.AddParameter("AssignmentID", assignmentID);
                        dbc.Fill(ds);

                        if (ds.Tables[0].Rows.Count <= 0)
                        {
                            continue;
                        }

                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            if (ds.Tables[0].Rows[i]["AssignmentID"] != DBNull.Value)
                            {
                                string   assignName     = ds.Tables[0].Rows[i]["ShortName"].ToString();
                                DateTime dueDate        = Convert.ToDateTime(ds.Tables[0].Rows[i]["DueDate"]);
                                string[] AssignmentInfo = new string[] { assignName, string.Format("{0:d}", dueDate) };

                                string pastDueSubject  = SharedSupport.GetLocalizedString("Notification_PastDueSubject", AssignmentInfo);
                                string pastDueBody     = SharedSupport.GetLocalizedString("Notification_PastDueBody", AssignmentInfo);
                                string reminderSubject = SharedSupport.GetLocalizedString("Notification_ReminderSubject", AssignmentInfo);
                                string reminderBody    = SharedSupport.GetLocalizedString("Notification_ReminderBody", AssignmentInfo);

                                TimeSpan difference = dueDate - DateTime.Today;
                                if (Convert.ToBoolean(ds.Tables[0].Rows[i]["SendPastDue"]) &&
                                    (difference.Days == -1 * Convert.ToInt32(ds.Tables[0].Rows[i]["PastDueWarningDays"])))
                                {
                                    UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"]));
                                    MessageM.SendMessage(sentByEmail, user.EmailAddress, pastDueSubject, pastDueBody);
                                }

                                if (Convert.ToBoolean(ds.Tables[0].Rows[i]["SendReminders"]) &&
                                    (difference.Days == Convert.ToInt32(ds.Tables[0].Rows[i]["ReminderWarningDays"])))
                                {
                                    UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"]));
                                    MessageM.SendMessage(sentByEmail, user.EmailAddress, reminderSubject, reminderBody);
                                }
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        SharedSupport.HandleError(ex);
                    }
                }
            }
            catch (System.Exception ex)
            {
                SharedSupport.HandleError(ex);
            }
            finally
            {
                // reset the interval for the next event
                timer.Interval = millisecondsToMidnight();

                // re-enable the timer
                timer.Enabled = true;
            }
        }