Exemplo n.º 1
0
        protected void ChangeUserBlockedStatus(object sender, EventArgs e)
        {
            dbHandler dbh = new dbHandler();

            dbh.changeIsBlocked(((Button)sender).Attributes["userName"], (((Button)sender).Text.Equals("Block")) ? 1 : 0);
            Response.Redirect(@"/ManageUsers.aspx");
        }
Exemplo n.º 2
0
        private void addFileToServer(Hashtable prms)
        {
            if (fu_addnewset.PostedFile != null && fu_addnewset.PostedFile.FileName != "")
            {
                string fullDestPath     = Server.MapPath("~/" + GlobalConsts.setsFolder + fu_addnewset.PostedFile.FileName);
                string relativeDestPath = GlobalConsts.setsFolder + fu_addnewset.PostedFile.FileName;
                fu_addnewset.PostedFile.SaveAs(fullDestPath);
                float speedPerformance    = 50;
                int   memoryPerformance   = 60;
                float percentageOfCovered = 22;
                int   sizeOfWord          = 3;
                int   amountOfMatch       = 5;
                bool  readSuccess         = GlobalFunctions.readSetFile(fullDestPath, out sizeOfWord, out amountOfMatch, out speedPerformance, out memoryPerformance, out percentageOfCovered);

                if (readSuccess)
                {
                    dbHandler dbh = new dbHandler();
                    dbh.insertNewSet(sizeOfWord, amountOfMatch, speedPerformance, memoryPerformance, percentageOfCovered, relativeDestPath);
                    prms.Add("speedPerformance", speedPerformance);//speedPerformance,memoryPerformance,percentageOfCovered
                    prms.Add("memoryPerformance", memoryPerformance);
                    prms.Add("percentageOfCovered", percentageOfCovered);
                    prms.Add("sizeOfWord", sizeOfWord);
                    prms.Add("amountOfMatch", amountOfMatch);
                    prms.Add("filepath", relativeDestPath);
                }
                else
                {
                    File.Delete(fullDestPath);
                }
            }
        }
Exemplo n.º 3
0
        protected void Send_Click(object sender, EventArgs e) // // בדיקה עם המסד נתונים שהסיסמה והיוזר של המשתמש מתאימים
        {
            dbHandler dbh            = new dbHandler();
            string    checklogininfo = dbh.checkLogin(UserName.Text, Password.Text);

            if (checklogininfo.ToLower() == "ok")
            {
                handleSession();
                if (Session["userInformation"] != null)
                {
                    clsUser currUser = (clsUser)Session["userInformation"];
                    if (currUser.IsBlocked)
                    {
                        Response.Write("<script>alert('user is blocked');</script>");
                        return;
                    }
                    if (currUser.IsManager)
                    {
                        Response.Redirect(@"welcome2!.aspx");
                    }
                    else
                    {
                        Response.Redirect(@"welcome!.aspx");
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('" + checklogininfo + "');</script>");
            }
        }
Exemplo n.º 4
0
        protected void deleteUserClick(object sender, EventArgs e)
        {
            dbHandler dbh = new dbHandler();

            dbh.deleteUser(((Button)sender).Attributes["userName"]);
            Response.Redirect(@"/ManageUsers.aspx");
        }
Exemplo n.º 5
0
        void fillData()
        {
            List <List <string> > topicsList = new List <List <string> >();
            List <List <string> > msgsList   = new List <List <string> >();
            dbHandler             dbh        = new dbHandler();

            clsUser currUser = (clsUser)Session["userInformation"];

            if (currUser.UserName == "admin")
            {
                currUser.IsManager = true;
            }


            if (Request.QueryString["tid"] != null && !Request.QueryString["tid"].Equals("") && !Request.QueryString["tid"].Equals(" "))
            {
                msgsList = dbh.getAllMsgs(Request.QueryString["tid"]);
                if (msgsList != null)
                {
                    showMsgsToTable(msgsList, currUser.IsManager);
                }
            }
            else
            {
                topicsList = dbh.getAllTopics();
                if (topicsList != null)
                {
                    showTopicsToTable(topicsList, currUser.IsManager);
                }
            }
        }
        protected void Get_Click(object sender, EventArgs e) // // בדיקה עם המסד נתונים שהסיסמה והיוזר של המשתמש מתאימים
        {
            dbHandler dal  = new dbHandler();
            Hashtable prms = new Hashtable();

            prms.Add("UsernameOrEmail", UserName.Text);
            DataSet ds = dal.GetData("usp_getUserEmail", prms);

            if (ds != null && ds.Tables != null && ds.Tables[0].Rows.Count > 0)
            {
                //UserName or Email recognized
                if (clsMail.SendMail(ds.Tables[0].Rows[0]["Email"].ToString(), "Password Reminder", ""))
                {
                    Response.Write("<script>alert('Your Password will be send to you in a couple of minutes');</script>");
                    Response.Redirect(@"/Login.aspx");
                }
                else
                {
                    Response.Write("<script>alert('Sending your password to your email failed. Please Make sure you have SMTP server on you server and try again');</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('The value you have inserted is not an Email not UserName in our dB');</script>");
            }


            //Response.Redirect(@"/ResetPassword.aspx");
        }
Exemplo n.º 7
0
        public static void PUTBook(Book book)
        {
            Console.WriteLine("Book added: " + book.Title);
            dbHandler db = new dbHandler();

            db.insertBook(book);
            bookList.Add(book);
            return;
        }
        private void makedatatable(bool useSession, Hashtable whereParams)
        {
            DataTable tbl = null;

            dbHandler dbh = new dbHandler();

            tbl = dbh.getSets(whereParams, sort.SelectedValue);

            if (tbl != null)
            {
                Session["allSets"] = tbl;
            }
            dbh = null;
            GC.Collect();

            StringBuilder sb_html = new StringBuilder();

            sb_html.Append("<table class='table table - hover'>");

            //Build the column names according to the data came from dB
            sb_html.Append("<thead><tr>");
            foreach (DataColumn col in tbl.Columns)
            {
                sb_html.Append("<th>" + col.ColumnName + "</th>");
            }
            sb_html.Append("<th>Search</th>");
            sb_html.Append("</tr></thead>");

            if (tbl != null)
            {
                //data has been found --> show table to client
                //Build the rows data according to the data came from dB
                sb_html.Append("<tbody>");
                foreach (DataRow row in tbl.Rows)
                {
                    sb_html.Append("<tr>");
                    foreach (DataColumn col in tbl.Columns)
                    {
                        if (col.ColumnName != "ViewFile")
                        {
                            sb_html.Append("<td>" + row[col.ColumnName].ToString() + "</td>");
                        }
                        else
                        {
                            string str = "onclick=\"viewFileData('" + row[col.ColumnName].ToString().Replace(@"\", "\\\\") + "');\"";
                            sb_html.Append("<td><button type='button' class='btn btn-info btn-lg' data-toggle='modal' " + str + " data -target='#myModal'>View</button></td>");
                        }
                    }
                    sb_html.Append("<td><a href='SearchSpecificWord.aspx?sizeOfWord=" + row["Size_Word"].ToString() + "&filepath=" + row["ViewFile"].ToString() + "' class='btn btn-info btn-lg'>Perform Search</a></td>");
                    sb_html.Append("</tr>");
                }
                sb_html.Append("</tbody>");
            }
            sb_html.Append("</table>");
            tableContainer.Text = sb_html.ToString();
        }
Exemplo n.º 9
0
        private void handleSession()
        {
            clsUser   currUser = (clsUser)Session["userInformation"];
            dbHandler dbh      = new dbHandler();

            dbh.changeIsStatus(currUser.UserName, 1);
            if (UserName.Text == "admin")
            {
                currUser.IsManager = true;
            }
        }
Exemplo n.º 10
0
        protected void onClickLogOut(object sender, EventArgs e)
        {
            clsUser currUser = (clsUser)Session["userInformation"];

            if (currUser != null)
            {
                dbHandler dbh = new dbHandler();
                dbh.changeIsStatus(currUser.UserName, Convert.ToByte(currUser.IsStatus));
                Session.Remove("userInformation");
                Session.Abandon();
                Response.Redirect(@"/Login.aspx");
            }
        }
Exemplo n.º 11
0
        protected void deleteTopicClick(object sender, EventArgs e)
        {
            Button btnDelete = (Button)sender;

            if (btnDelete != null && btnDelete.Attributes != null && btnDelete.Attributes["ID"] != null)
            {
                string    msgID = btnDelete.Attributes["ID"].ToString();
                dbHandler dbh   = new dbHandler();
                if (dbh.deleteForumTopic(Convert.ToInt32(msgID)))
                {
                    //Succesfully Deleted
                    //refresh data so the deleted row wont be shown anymore
                    fillData();
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// This function change approval status the specific MESSAGE that been clicked in the table.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void changeMsgApprovalClick(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn != null && btn.Attributes != null && btn.Attributes["msgID"] != null)
            {
                bool isApproved = true;
                if (btn.Text == "Disapprove")
                {
                    isApproved = false;
                }

                string    msgID = btn.Attributes["msgID"].ToString();
                dbHandler dbh   = new dbHandler();
                if (dbh.SetForumMessageApproveDisapprove(Convert.ToInt32(msgID), isApproved))
                {
                    //Succesfully change approve/disapproved in db --> change button text
                    btn.Text = (isApproved ? "Disapprove" : "Approve");
                }
            }
        }
Exemplo n.º 13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["userInformation"] != null)
     {
         clsUser currUser = (clsUser)Session["userInformation"];
         if (!currUser.IsManager)
         {
             Response.Redirect(@"welcome!.aspx");
         }
         else
         {
             //current user is manager
             List <List <string> > usersList = new List <List <string> >();
             dbHandler             dbh       = new dbHandler();
             usersList = dbh.getAllUsers();
             if (usersList != null)
             {
                 showUsersToTable(usersList);
             }
         }
     }
 }
        protected void Send_Click(object sender, EventArgs e) // User click on send button
        {
            if (MCS.Text == "")
            {
                Response.Write("<script>alert('MCS is mandatory. Please fill it and click Send again');</script>");
                return;
            }


            if (AmmountOfMatch.Text == "")
            {
                Response.Write("<script>alert('AmmountOfMatch is mandatory. Please fill it and click Send again');</script>");
                return;
            }

            if (WordSize.Text == "")
            {
                Response.Write("<script>alert('WordSize is mandatory. Please fill it and click Send again');</script>");
                return;
            }

            int    z = Convert.ToInt32(MCS.Text);
            int    x = Convert.ToInt32(AmmountOfMatch.Text);
            int    y = Convert.ToInt32(WordSize.Text);
            double w = (double)x / y;

            if (w < 0.6)
            {
                Response.Write("<script>alert('(AmmountOfMatch/WordSize) *100 < 60, Please fill it and click Send again');</script>");
                return;
            }
            if (z > x)
            {
                Response.Write("<script>alert('MCS > AmmountOfMatch, Please fill it and click Send again');</script>");
                return;
            }


            string algorithmPath = Server.MapPath("/BasicAlgorithm/Release/main.exe");
            string relativePath  = "/SetFiles/forms_" + DateTime.Now.ToString("yyyyMMddHHmmssffff");
            string pathToSave    = Server.MapPath(relativePath);

            ///  if (MCS.Text == " ")
            /// {
            //  (MCS.Text = "4";

            ///  }
            //string pathToSave = Server.MapPath("/SetFiles/forms_" + DateTime.Now.ToString("yyyyMMddHHmmssffff"));


            string str = string.Concat(WordSize.Text, " ", AmmountOfMatch.Text, " ", MCS.Text, " ", pathToSave);

            // string str = "20 12 5 path";

            Process.Start(algorithmPath, str);//////לקחת את הקובץ הפעלה של זכריה ולא של לבנת!!!!
            //Console.ReadKey();

            //להמתין עד ליצירת הקובץ. בודקים כל 8 שניות
            while (!File.Exists(pathToSave))
            {
                System.Threading.Thread.Sleep(8000);
            }

            float speedPerformance    = 50;
            int   memoryPerformance   = 60;
            float percentageOfCovered = 22;
            int   sizeOfWord          = 3;
            int   amountOfMatch       = 5;
            bool  readSuccess         = GlobalFunctions.readSetFile(pathToSave, out sizeOfWord, out amountOfMatch, out speedPerformance, out memoryPerformance, out percentageOfCovered);

            if (readSuccess)
            {
                dbHandler dbh = new dbHandler();
                dbh.insertNewSet(sizeOfWord, amountOfMatch, speedPerformance, memoryPerformance, percentageOfCovered, relativePath);
                Response.Redirect(@"/PerformanceSetOfFilters.aspx?amountOfMatch=" + amountOfMatch + "&speedPerformance=" + speedPerformance + "&memoryPerformance=" + memoryPerformance + "&percentageOfCovered=" + percentageOfCovered + "&sizeOfWord=" + sizeOfWord + "&filepath=" + relativePath); // עדיין אין מסך כזה - ליצור את המסך הזה
            }
            else
            {
                File.Delete(pathToSave);
            }
        }
Exemplo n.º 15
0
        private void makedatatable(int WordSize, int NumOfMatches)
        {
            DataTable tbl = null;

            //Table data will be taken from Database
            dbHandler dbh  = new dbHandler();
            Hashtable prms = new Hashtable();

            prms.Add("WordSize", WordSize);
            prms.Add("NumOfMatches", NumOfMatches);

            DataSet ds = dbh.GetData("usp_GetAllSets", prms);

            if (ds != null && ds.Tables != null)
            {
                tbl = ds.Tables[0];
            }

            //dbh = null;
            GC.Collect();

            StringBuilder sb_html = new StringBuilder();

            sb_html.Append("<table class='table table - hover'>");

            //Build the column names according to the data came from dB
            sb_html.Append("<thead><tr>");
            foreach (DataColumn col in tbl.Columns)
            {
                sb_html.Append("<th>" + col.ColumnName + "</th>");
            }

            sb_html.Append("<th>Operation</th>");
            sb_html.Append("</tr></thead>");

            if (tbl != null)
            {
                //data has been found --> show table to client
                //Build the rows data according to the data came from dB
                sb_html.Append("<tbody>");
                foreach (DataRow row in tbl.Rows)
                {
                    sb_html.Append("<tr>");
                    foreach (DataColumn col in tbl.Columns)
                    {
                        if (col.ColumnName != "ViewFile")
                        {
                            sb_html.Append("<td>" + row[col.ColumnName].ToString() + "</td>");
                        }
                        else
                        {
                            string str = "onclick=\"viewFileData('" + row[col.ColumnName].ToString().Replace(@"\", "\\\\") + "');\"";
                            sb_html.Append("<td><button type='button' class='btn btn - info btn - lg' data-toggle='modal' " + str + " data -target='#myModal'>View</button></td>");
                        }
                    }
                    string deleteClick = "onclick=\"deleteSet(" + row["Set_Id"].ToString() + ");\"";
                    sb_html.Append("<td><button type='button' class='btn btn - info btn - lg'" + deleteClick + "'>Delete Set</button></td>");
                    sb_html.Append("</tr>");
                }
                sb_html.Append("</tbody>");
            }
            sb_html.Append("</table>");
            tableContainer.Text = sb_html.ToString();
        }
Exemplo n.º 16
0
        protected void Send_Click(object sender, EventArgs e) // User click on send button
        {
            // TODO: VALIDATE LENGTHS OF FIELDS AND EMAIL VALIDATION (IS EXISTS)
            dbHandler dbh = new dbHandler();

            if (!UserName.Text.Equals("") && !Password.Text.Equals("") && !ConfirmPassword.Text.Equals("") &&
                !LastName.Text.Equals("") && !FirstName.Text.Equals("") && !Email.Text.Equals(""))
            {
                bool isLenghtOK = true;

                if (UserName.Text.Length > 50)
                {
                    isLenghtOK         = false;
                    UserName.BackColor = Color.Red;
                    UserName.ForeColor = Color.White;
                    Response.Write("<script>alert('שם המשתמש שכתבת ארוך מדי. נא לכתוב מקסימום 50 תווים');</script>");
                }
                else
                {
                    UserName.BackColor = Color.White;
                    UserName.ForeColor = Color.Black;
                }
                if (Password.Text.Length > 10)
                {
                    isLenghtOK         = false;
                    Password.BackColor = Color.Red;
                    Password.ForeColor = Color.White;
                    Response.Write("<script>alert('הסיסמא שכתבת ארוכה מדי. נא לכתוב מקסימום 10 תווים');</script>");
                }
                else
                {
                    Password.BackColor = Color.White;
                    Password.ForeColor = Color.Black;
                }

                if (Password.Text != ConfirmPassword.Text)
                {
                    isLenghtOK         = false;
                    Password.BackColor = Color.Red;
                    Password.ForeColor = Color.White;
                    Response.Write("<script>alert('Password is different than confirm password');</script>");
                }
                else
                {
                    Password.BackColor = Color.White;
                    Password.ForeColor = Color.Black;
                }

                if (isLenghtOK)
                {
                    string checkUserInDBResult = dbh.isUserExists(UserName.Text, Email.Text);
                    if (checkUserInDBResult != "")
                    {
                        Response.Write("<script>alert('" + checkUserInDBResult + "');</script>");
                    }
                    else
                    {
                        //user does not exist-->can be saved
                        if (dbh.insertNewUser(UserName.Text, FirstName.Text, LastName.Text, Password.Text, Email.Text))
                        {
                            Response.Write("<script>alert('הרשמתך הסיימה בהצלחה');window.open('StudentPage.html','_self');</script>");
                            clsUser currUser = new clsUser();
                            currUser.Email             = Email.Text;
                            currUser.FirstName         = FirstName.Text;
                            currUser.IsBlocked         = false;
                            currUser.IsManager         = false;
                            currUser.IsStatus          = 0;
                            currUser.LastName          = LastName.Text;
                            currUser.UserName          = UserName.Text;
                            Session["userInformation"] = currUser;
                        }
                        else
                        {
                            Response.Write("<script>alert('עכב תקלת מערכת, הרשמתך נכשלה. לנסות שוב');</script>");
                        }
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('Some fields are empty');</script>");
            }
        }
Exemplo n.º 17
0
        protected void Send_Click(object sender, EventArgs e) // User click on send button
        {
            // TODO: VALIDATE LENGTHS OF FIELDS AND EMAIL VALIDATION (IS EXISTS)
            dbHandler dbh = new dbHandler();

            if (!UserName.Text.Equals("") && !Password.Text.Equals("") && !ConfirmPassword.Text.Equals("") &&
                !LastName.Text.Equals("") && !FirstName.Text.Equals("") && !Email.Text.Equals(""))
            {
                bool isLenghtOK = true;

                if (UserName.Text.Length > 50)
                {
                    isLenghtOK         = false;
                    UserName.BackColor = Color.Red;
                    UserName.ForeColor = Color.White;
                    Response.Write("<script>alert('User name is limited to 50 characters');</script>");
                }
                else
                {
                    UserName.BackColor = Color.White;
                    UserName.ForeColor = Color.Black;
                }
                if (Password.Text.Length > 10)
                {
                    isLenghtOK         = false;
                    Password.BackColor = Color.Red;
                    Password.ForeColor = Color.White;
                    Response.Write("<script>alert('Password is limited to 10 characters');</script>");
                }
                else
                {
                    Password.BackColor = Color.White;
                    Password.ForeColor = Color.Black;
                }

                if (Password.Text != ConfirmPassword.Text)
                {
                    isLenghtOK         = false;
                    Password.BackColor = Color.Red;
                    Password.ForeColor = Color.White;
                    Response.Write("<script>alert('Password has to be identical');</script>");
                }
                else
                {
                    Password.BackColor = Color.White;
                    Password.ForeColor = Color.Black;
                }

                if (isLenghtOK)
                {
                    string checkUserInDBResult = dbh.isUserExists(UserName.Text, Email.Text);
                    if (checkUserInDBResult != "")
                    {
                        Response.Write("<script>alert('" + checkUserInDBResult + "');</script>");
                    }
                    else
                    {
                        //user does not exist-->can be saved
                        if (dbh.insertNewUser(UserName.Text, FirstName.Text, LastName.Text, Password.Text, Email.Text))
                        {
                            Response.Write("<script>alert('Register Successful');window.open('WELCOME!.aspx','_self');</script>");
                            clsUser currUser = new clsUser();
                            currUser.Email             = Email.Text;
                            currUser.FirstName         = FirstName.Text;
                            currUser.IsBlocked         = false;
                            currUser.IsManager         = false;
                            currUser.IsStatus          = 0;
                            currUser.LastName          = LastName.Text;
                            currUser.UserName          = UserName.Text;
                            Session["userInformation"] = currUser;
                        }
                        else
                        {
                            Response.Write("<script>alert('Register Fails');</script>");
                        }
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('Some fields are empty');</script>");
            }
        }