public static CourseM Load(System.Guid courseGUID)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_LoadCourseByGUID", DBCallType.Select);

            dbc.AddParameter("@CourseGUID", courseGUID);
            return(LoadCourseFromDatabase(dbc));
        }
        public static CourseM Load(string courseName)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_LoadCourseByName", DBCallType.Select);

            dbc.AddParameter("@ShortName", courseName);
            return(LoadCourseFromDatabase(dbc));
        }
        public void DeleteResource(int resourceID)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_DeleteResource", DBCallType.Execute);

            dbc.AddParameter("@CourseResourceID", resourceID);
            dbc.Execute();
        }
        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);
        }
        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);
        }
        public void ClearStarter()
        {
            DatabaseCall dbc = new DatabaseCall("Assignments_ClearStarter", DBCallType.Execute);

            dbc.AddParameter("@AssignmentID", _assignmentID);
            dbc.Execute();
        }
        internal static void Delete(int assignid)
        {
            DatabaseCall dbc = new DatabaseCall("Assignments_Purge", DBCallType.Execute);

            dbc.AddParameter("@AssignmentID", assignid);
            dbc.Execute();
        }
        public static UserM LoadByUniversityID(string universityID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByUniversityID", DBCallType.Select);

            dbc.AddParameter("@UniversityID", universityID);

            return(LoadUserFromDatabase(dbc));
        }
        public static UserM LoadByUserName(string username)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByUsername", DBCallType.Select);

            dbc.AddParameter("@UserName", username);

            return(LoadUserFromDatabase(dbc));
        }
Beispiel #10
0
        private void AddFile(string filename)
        {
            DatabaseCall dbc = new DatabaseCall("StudentAssignments_AddFile", DBCallType.Execute);

            dbc.AddParameter("@UserAssignmentID", _userAssignmentID);
            dbc.AddParameter("@FileName", filename);
            dbc.Execute();
        }
        public static void RemoveFromCourse(int userID, int courseID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_Purge", DBCallType.Execute);

            dbc.AddParameter("@UserID", userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.Execute();
        }
        public static UserM LoadByEmail(string email)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByEmail", DBCallType.Select);

            dbc.AddParameter("@Email", email);

            return(LoadUserFromDatabase(dbc));
        }
        public static UserM Load(int userID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_LoadUserByUserID", DBCallType.Select);

            dbc.AddParameter("@UserID", userID);

            return(LoadUserFromDatabase(dbc));
        }
Beispiel #14
0
        public void ClearSubmissions()
        {
            DatabaseCall dbc = new DatabaseCall("StudentAssignments_ClearSubmissions", DBCallType.Execute);

            dbc.AddParameter("@UserID", _userID);
            dbc.AddParameter("@AssignmentID", _assignmentID);

            dbc.Execute();
        }
Beispiel #15
0
        public static void SetRoleInCourse(int userID, int courseID, int roleID)
        {
            DatabaseCall dbc = new DatabaseCall("Roles_UpdateRoleInCourse", DBCallType.Execute);

            dbc.AddParameter("@UserID", userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.AddParameter("@RoleID", roleID);
            dbc.Execute();
        }
        public void AddResource(string name, string resourceValue)
        {
            DatabaseCall dbc = new DatabaseCall("Courses_AddResource", DBCallType.Execute);

            dbc.AddParameter("@CourseID", _courseID);
            dbc.AddParameter("@Name", name);
            dbc.AddParameter("@ResourceValue", resourceValue);
            dbc.Execute();
        }
        private int SaveAssignmentToDatabase(StoredProcType procType)
        {
            int          retID = 0;
            DatabaseCall dbc   = null;

            switch (procType)
            {
            case StoredProcType.New:
                dbc = new DatabaseCall("Assignments_AddNewAssignment", DBCallType.Execute);
                dbc.AddOutputParameter("@AssignmentID");
                dbc.AddOutputParameter("@CourseAssignmentID");
                break;

            case StoredProcType.Update:
                dbc = new DatabaseCall("Assignments_UpdateExistingAssignment", DBCallType.Execute);
                dbc.AddParameter("@AssignmentID", this.AssignmentID);
                break;

            default:
                throw new Exception("Invalid Stored Procedure");
            }

            dbc.AddParameter("@ShortName", this.ShortName);
            dbc.AddNTextParameter("@Description", this.Description);
            dbc.AddParameter("@LastUpdatedDate", this.LastUpdatedDate);
            dbc.AddParameter("@LastUpdatedUserID", this.LastUpdatedUserID);
            dbc.AddParameter("@StarterProjectFlag", this.StarterProjectFlag);
            dbc.AddParameter("@MakeFile", this.MakeFile);
            dbc.AddParameter("@CompilerType", this.CompilerType);
            dbc.AddParameter("@CourseID", this.CourseID);
            dbc.AddParameter("@DueDate", this.DueDate);
            dbc.AddParameter("@MultipleSubmitsFlag", this.MultipleSubmitsFlag);
            dbc.AddParameter("@SendReminders", this.SendReminders);
            dbc.AddParameter("@AutoGradeFlag", this.AutoGradeFlag);
            dbc.AddParameter("@InputFile", this.InputFile);              // set to either DBNull or String Valu);
            dbc.AddParameter("@OutputFile", this.OutputFile);            // set to either DBNull or String Valu);
            dbc.AddParameter("@GradeType", this.GradeType);
            dbc.AddParameter("@AutoCompileFlag", this.AutoCompileFlag);
            dbc.AddParameter("@AssignmentURL", this.AssignmentURL);               // set to either DBNull or String Valu);
            dbc.AddParameter("@CommandLineArgs", this.CommandLineArgs);
            dbc.AddParameter("@SendPastDue", this.SendPastDue);
            dbc.AddParameter("@SendNewProject", this.SendNewProject);
            dbc.AddParameter("@SendUpdatedProject", this.SendUpdatedProject);
            dbc.AddParameter("@PastDueWarningDays", this.PastDueWarningDays);
            dbc.AddParameter("@ReminderWarningDays", this.ReminderWarningDays);

            dbc.Execute();

            if (procType == StoredProcType.New)
            {
                retID = Convert.ToInt32(dbc.GetOutputParam("@AssignmentID"));
                _courseAssignmentID = Convert.ToInt32(dbc.GetOutputParam("@CourseAssignmentID"));
            }

            return(retID);
        }
        internal void AddToCourse(int courseID, PermissionsID roleID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_AddToCourse", DBCallType.Execute);

            dbc.AddParameter("@UserID", _userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.AddParameter("RoleID", (int)roleID);

            dbc.Execute();
        }
        public void ImportToCourse(int courseID, string importID)
        {
            DatabaseCall dbc = new DatabaseCall("Users_ImportToCourse", DBCallType.Execute);

            dbc.AddParameter("@UserID", _userID);
            dbc.AddParameter("@CourseID", courseID);
            dbc.AddParameter("@ImportID", importID);

            dbc.Execute();
        }
Beispiel #20
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);
        }
        public void SetPassword(string password, bool hasChanged)
        {
            Byte[] passwd         = SharedSupport.ConvertStringToByteArray(password.Trim());
            byte[] hashValue      = ((HashAlgorithm)CryptoConfig.CreateFromName(Constants.HashMethod)).ComputeHash(passwd);
            string hashedPassword = BitConverter.ToString(hashValue);


            DatabaseCall dbc = new DatabaseCall("Users_ChangePassword", DBCallType.Execute);

            dbc.AddParameter("@UserID", _userID);
            dbc.AddParameter("@Password", hashedPassword);
            dbc.AddParameter("@ChangedPassword", hasChanged);
            dbc.Execute();
        }
        private int saveCourseToDatabase(CourseStoredProcType sprocType)
        {
            DatabaseCall dbc;
            int          retID = 0;

            if (sprocType == CourseStoredProcType.Add)
            {
                dbc = new DatabaseCall("Courses_AddNewCourse", DBCallType.Execute);
                dbc.AddOutputParameter("@CourseID");
            }
            else if (sprocType == CourseStoredProcType.Update)
            {
                dbc = new DatabaseCall("Courses_UpdateExistingCourse", DBCallType.Execute);
                dbc.AddParameter("@CourseID", this._courseID);
            }
            else
            {
                throw new Exception("Unknown Stored Procedure Type");
            }

            dbc.AddParameter("@CourseGUID", _courseGUID);
            dbc.AddParameter("@ShortName", _courseName);
            dbc.AddNTextParameter("@Description", _description);
            dbc.AddParameter("@LastUpdatedDate", System.DateTime.Now);
            dbc.AddParameter("@LastUpdatedUserID", _lastUpdatedUserID);
            dbc.AddParameter("@HomepageURL", _homepageURL);
            dbc.AddParameter("@MultipleSubmitsFlag", false);
            dbc.AddParameter("@SendEmailRemindersFlag", _sendEmailRemindersFlag);
            dbc.AddParameter("@StartDate", _startDate);
            dbc.AddParameter("@EndDate", _endDate);
            dbc.AddParameter("@RootStoragePath", _rootStoragePath);

            dbc.Execute();

            if (sprocType == CourseStoredProcType.Add)
            {
                try
                {
                    retID          = Convert.ToInt32(dbc.GetOutputParam("@CourseID"));
                    this._courseID = retID;
                }
                catch
                {
                }
            }
            //Write course data to file
            saveCourseXML();
            return(retID);
        }
Beispiel #23
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);
        }
Beispiel #25
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));
            }
        }
        private int saveUserToDatabase(StoredProcType sprocType)
        {
            DatabaseCall dbc;
            int          retID = 0;

            if (sprocType == StoredProcType.Create)
            {
                dbc = new DatabaseCall("Users_CreateNew", DBCallType.Execute);
                dbc.AddOutputParameter("@UserID");
            }
            else if (sprocType == StoredProcType.Update)
            {
                dbc = new DatabaseCall("Users_UpdateExisting", DBCallType.Execute);
                dbc.AddParameter("@UserID", _userID);
            }
            else
            {
                throw new Exception("Unknown Stored Procedure Type");
            }

            dbc.AddParameter("@LastName", _lastName);
            dbc.AddParameter("FirstName", _firstName);
            dbc.AddParameter("@MiddleName", _middleName);
            dbc.AddParameter("@Email", _emailAddress);
            dbc.AddParameter("@UniversityIdentifier", _universityID);
            dbc.AddParameter("@UserName", _username);
            dbc.AddParameter("@Password", _password);
            dbc.AddParameter("@LastUpdatedDate", _lastUpdatedDate);
            dbc.AddParameter("@LastUpdatedUserID", _lastUpdatedUserID);
            dbc.AddParameter("@ChangedPassword", _changedPassword);

            dbc.Execute();
            if (sprocType == StoredProcType.Create)
            {
                retID        = Convert.ToInt32(dbc.GetOutputParam("@UserID"));
                this._userID = retID;
            }

            return(retID);
        }
Beispiel #27
0
        private void SaveToDatabase(StoredProcType procType)
        {
            DatabaseCall dbc;

            switch (procType)
            {
            case StoredProcType.New:

                dbc = new DatabaseCall("StudentAssignments_AddNewAssignment", DBCallType.Execute);
                dbc.AddOutputParameter("@UserAssignmentID");
                break;

            case StoredProcType.Update:
                dbc = new DatabaseCall("StudentAssignments_UpdateExistingAssignment", DBCallType.Execute);
                break;

            default:
                throw new Exception("Invalid Stored Procedure");
            }

            dbc.AddParameter("@UserID", this._userID);
            dbc.AddParameter("@AssignmentID", this._assignmentID);
            dbc.AddParameter("@LastSubmitDate", this._lastSubmitDate);
            dbc.AddParameter("@LastUpdatedDate", this._lastUpdatedDate);
            dbc.AddParameter("@OverallGrade", this._overallGrade);
            dbc.AddNTextParameter("@GradeComments", this._gradeComments);
            dbc.AddParameter("@AutoCompileStatus", this._autoCompileStatus);
            dbc.AddParameter("@AutoGradeStatus", this._autoGradeStatus);
            dbc.AddNTextParameter("@BuildDetails", this._buildDetails);
            dbc.AddNTextParameter("@CheckDetails", this._checkDetails);
            dbc.AddParameter("@BuildResultCode", this._buildResultCode);
            dbc.AddParameter("@CheckResultCode", this._checkResultCode);

            dbc.Execute();

            if (procType == StoredProcType.New)
            {
                this._userAssignmentID = Convert.ToInt32(dbc.GetOutputParam("@UserAssignmentID"));
            }
        }
        /// <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);
            }
        }
Beispiel #29
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;
            }
        }