コード例 #1
0
ファイル: Global.asax.cs プロジェクト: PF2000/AppLabRedes
        public void SaveUsers(DataTable dt)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                TextBox txt = new TextBox();
                ActiveDirectory ad = new ActiveDirectory();

                foreach (DataRow row in dt.Rows) // Loop over the items.
                {
                    String userName = row["usr"].ToString();
                    String pwd = row["pass"].ToString();
                    //DateTime dateTime = (DateTime)row["tEnd"];
                    ad.CreateUser(sb, userName, pwd);
                    ad.AddUserToGroup(userName, "RadiusUsers");
                }
                SqlCode.UpdateDB(dt, 1);
                EmailClass.SendEmails(dt);
                SqlCode.copyDataEventLogger("Successfully created users", "success", sb.ToString());
                errorAdd = false;
            }
            catch (Exception ex)
            {
                if(errorAdd == false)
                    SqlCode.copyDataEventLogger("Error creating users", "danger", ex.Message);
                errorAdd = true;
            }
        }
コード例 #2
0
ファイル: EditCourse.aspx.cs プロジェクト: PF2000/AppLabRedes
        public void RemoveUsers(DataTable dt)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                //TextBox txt = new TextBox();
                ActiveDirectory ad = new ActiveDirectory();

                foreach (DataRow row in dt.Rows) // Loop over the items.
                {
                    String userName = row["usr"].ToString();
                    ad.DeleteUser(sb, userName);
                }
                //SqlCode.UpdateDB(dt, 2);
                SqlCode.copyDataEventLogger("Successfully deleted users", "success", sb.ToString());

                errorRemove = false;
            }
            catch (Exception ex)
            {
                if (errorRemove == false)
                    SqlCode.copyDataEventLogger("Error removing users", "danger", ex.Message);
                errorRemove = true;
            }
        }
コード例 #3
0
ファイル: Courses.aspx.cs プロジェクト: PF2000/AppLabRedes
        /// <summary>
        /// Button for course removal
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRemoveCourse_Command(object sender, CommandEventArgs e)
        {
            try
            {
                //gets the id from button parameters
                int idCourse = Convert.ToInt16(e.CommandArgument.ToString());

                StringBuilder sb = new StringBuilder();

                ActiveDirectory ad = new ActiveDirectory();
                DataTable dt = SqlCode.PullDataToDataTable("select usr from tblUsers where course = '" + idCourse + "'");

                foreach (DataRow row in dt.Rows) // Loop over the items.
                {
                    ad.DeleteUser(sb, row["usr"].ToString());
                }

                //adds the labTypes to database
                RemoveUsers(idCourse);
                //adds the labTypes to database
                RemoveLogTimes(idCourse);
                //remove lab
                RemoveCourse(idCourse);
                //PostBack
                Response.Redirect("~/Course/Courses?op=deleteSuccess");
            }
            catch (Exception ex)
            {
                //error message
                cphErrorMessage.Visible = true;
                txtOutput.Text = "Error deleting user!! " + ex.Message;
            }
        }