public void button1_Click_1(object sender, EventArgs e) { Form2 newForm = new Form2(); newForm.Show(); Result.result.Clear(); Form2.WriteTreeList.Clear(); Form2.WriteTreeList.Add("Nothing"); Form2.treeView1.Nodes.Clear(); Client a = new Client(); if (!CheckErrors.isPathExists(Path.GetFullPath(textBox1.Text))) { MessageBox.Show(Error.GetErrorMsg(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Thread FindFileThread = new Thread(new ThreadStart(delegate { a.Find(Path.GetFullPath(textBox1.Text), textBox2.Text + "\n"); MessageBox.Show("Done \n", "Справка", MessageBoxButtons.OK, MessageBoxIcon.Information); })); FindFileThread.Priority = ThreadPriority.Highest; FindFileThread.Start(); } }
protected bool checkInputs() { bool correct = true; CheckErrors errors = new CheckErrors(); string p1, p2, p3; if (!errors.validPassword(txtP1.Text, out p1)) { correct = false; lblP1Error.Visible = true; lblP1Error.Text = p1; txtP1.Focus(); } if (!errors.validPassword(txtP2.Text, out p2)) { correct = false; lblP2Error.Visible = true; lblP2Error.Text = p2; txtP2.Focus(); } if (!errors.passwordsMatch(txtP1.Text, txtP2.Text, out p3)) { correct = false; lblError.Visible = true; lblError.Text = p3; txtP1.Focus(); } return(correct); }
protected bool isTopicCorrect() { bool correct = true; CheckErrors errors = new CheckErrors(); //check if id contains a special character: if (!errors.isDigit(topicId)) { correct = false; } //check if id contains an id that does not exist in DB: else if (errors.ContainsSpecialChars(topicId)) { correct = false; } if (correct) { connect.Open(); SqlCommand cmd = connect.CreateCommand(); //Count the existance of the topic: cmd.CommandText = "select count(*) from Topics where topicId = '" + topicId + "' "; int count = Convert.ToInt32(cmd.ExecuteScalar()); if (count > 0)//if count > 0, then the topic ID exists in DB. { cmd.CommandText = "select topic_createdBy from Topics where topicId = '" + topicId + "' "; string creatorId = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select userId from Users where loginId = '" + loginId + "' "; string userId = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select topic_isDeleted from Topics where topicId = '" + topicId + "' "; int isDeleted = Convert.ToInt32(cmd.ExecuteScalar()); cmd.CommandText = "select topic_isTerminated from Topics where topicId = '" + topicId + "' "; int isTerminated = Convert.ToInt32(cmd.ExecuteScalar()); cmd.CommandText = "select topic_type from topics where topicId = '" + topicId + "' "; string topic_type = cmd.ExecuteScalar().ToString(); //check if id belongs to a different user: //if (!userId.Equals(creatorId)) // correct = false; //else if (isDeleted == 1) { correct = false; } else if (isTerminated == 1) { correct = false; } if (topic_type.Equals("Dissemination")) { correct = false; } } else { correct = false; // means that the topic ID does not exists in DB. } connect.Close(); } return(correct); }
protected void Page_Load(object sender, EventArgs e) { initialPageAccess(); CheckErrors check = new CheckErrors(); try { g_testCaseId = Request.QueryString["id"]; if (!check.checkTestCaseAccess(g_testCaseId, loginId)) { goBack(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); goBack(); } if (!IsPostBack) { files = new List <HttpPostedFile>(); fillInputs(); } //The below to be used whenever needed in the other page: Session.Add("projectId", g_projectId); Session.Add("userStoryId", g_userStoryId); Session.Add("sprintTaskId", g_sprintTaskId); Session.Add("testCaseId", g_sprintTaskId); updateUniqueId(); checkIfTestCaseDeleted(); }
protected void Page_Load(object sender, EventArgs e) { initialPageAccess(); CheckErrors check = new CheckErrors(); try { g_sprintTaskId = Request.QueryString["sprintTaskId"]; if (!check.checkSprintTaskAccess(g_sprintTaskId, loginId)) { goBack(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); goBack(); } //Check if the user editing is the master of this project or an admin: if (!isAccessAllowed()) { goBack(); } if (!IsPostBack) { fillInputs(); files = new List <HttpPostedFile>(); } //The below to be used whenever needed in the other page. Most likely to be used in ViewUserStory page: Session.Add("projectId", g_projectId); Session.Add("userStoryId", g_userStoryId); Session.Add("sprintTaskId", g_sprintTaskId); updateUniqueId(); checkIfSprintTaskDeleted(); }
protected void Page_Load(object sender, EventArgs e) { initialAccess(); CheckErrors check = new CheckErrors(); try { if (!string.IsNullOrWhiteSpace(Request.QueryString["userStoryId"])) { userStoryId = Request.QueryString["userStoryId"]; if (!check.checkUserStoryAccess(userStoryId, loginId)) { goBack(); } } } catch (Exception ex) { Console.WriteLine("Error: " + ex); goBack(); } //Check if the user editing is the master of this project or an admin: if (!isAccessAllowed()) { goBack(); } if (!IsPostBack) { fillInputs(); files = new List <HttpPostedFile>(); } Session.Add("userStoryId", userStoryId); updateUniqueId(); checkIfUserStoryDeleted(); }
protected static bool isMessageCorrect(string messageId, string creatorId) { Configuration config = new Configuration(); SqlConnection connect = new SqlConnection(config.getConnectionString()); bool correct = true; CheckErrors errors = new CheckErrors(); //check if id contains a special character: if (!errors.isDigit(messageId)) { correct = false; } //check if id contains an id that does not exist in DB: else if (errors.ContainsSpecialChars(messageId)) { correct = false; } if (correct) { connect.Open(); SqlCommand cmd = connect.CreateCommand(); //Count the existance of the message: cmd.CommandText = "select count(*) from Entries where entryId = '" + messageId + "' "; int count = Convert.ToInt32(cmd.ExecuteScalar()); if (count > 0)//if count > 0, then the message ID exists in DB. { //Get creator ID: cmd.CommandText = "select userId from Entries where entryId = '" + messageId + "' "; string actual_creatorId = cmd.ExecuteScalar().ToString(); //Get the current user's ID who is trying to access the message: //cmd.CommandText = "select userId from Users where loginId = '" + loginId + "' "; //string userId = cmd.ExecuteScalar().ToString(); //Get the deletion's status: cmd.CommandText = "select entry_isDeleted from Entries where entryId = '" + messageId + "' "; int isDeleted = Convert.ToInt32(cmd.ExecuteScalar()); //check if id belongs to a different user: //Admins can delete anything! //if (!userId.Equals(creatorId)) // correct = false; //else if (isDeleted == 1) { correct = false; } } else { correct = false; // means that the topic ID does not exists in DB. } connect.Close(); } return(correct); }
protected void Page_Load(object sender, EventArgs e) { initialPageAccess(); CheckErrors check = new CheckErrors(); try { if (Request.QueryString["id"] != null) { g_testCaseId = Request.QueryString["id"]; if (!check.checkTestCaseAccess(g_testCaseId, loginId)) { goBack(); } if (Request.QueryString["sprintTaskId"] != null) { g_sprintTaskId = Request.QueryString["sprintTaskId"]; } if (Request.QueryString["userStoryId"] != null) { g_userStoryId = Request.QueryString["userStoryId"]; } if (Request.QueryString["projectId"] != null) { g_projectId = Request.QueryString["projectId"]; } } else { goBack(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); goBack(); } if (!IsPostBack) { connect.Open(); try { getTestCaseInfo(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.ToString()); } connect.Close(); } //The below to be used whenever needed in the other page. Most likely to be used in ViewSprintTask page: Session.Add("testCaseId", g_testCaseId); checkIfTestCaseTerminated(); }
protected bool isAccountCorrect() { bool correct = true; CheckErrors errors = new CheckErrors(); //check if id contains a special character: if (!errors.isDigit(accountId)) { correct = false; } //check if id contains an id that does not exist in DB: else if (errors.ContainsSpecialChars(accountId)) { correct = false; } if (correct) { connect.Open(); SqlCommand cmd = connect.CreateCommand(); //Count the existance of the user: cmd.CommandText = "select count(*) from Users where userId = '" + accountId + "' "; int count = Convert.ToInt32(cmd.ExecuteScalar()); if (count > 0)//if count > 0, then the user ID exists in DB. { //Get the current user's ID who is trying to access the profile: cmd.CommandText = "select userId from Users where loginId = '" + loginId + "' "; string current_userId = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select loginId from users where userId = '" + accountId + "' "; string account_loginId = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select login_isActive from Logins where loginId = '" + account_loginId + "' "; int isActive = Convert.ToInt32(cmd.ExecuteScalar()); if (isActive == 0) { correct = false; } //Maybe later use the current user's ID to check if the current user has access to view the selected profile. if (account_loginId == loginId) { correct = false; } } else { correct = false; // means that the user ID does not exists in DB. } connect.Close(); } return(correct); }
protected static bool isTestCaseCorrect(string testCaseId, string creatorId) { bool correct = true; CheckErrors errors = new CheckErrors(); //check if id contains a special character: if (!errors.isDigit(testCaseId)) { correct = false; } //check if id contains an id that does not exist in DB: else if (errors.ContainsSpecialChars(testCaseId)) { correct = false; } if (correct) { Configuration config = new Configuration(); SqlConnection connect = new SqlConnection(config.getConnectionString()); SqlCommand cmd = connect.CreateCommand(); connect.Open(); //Count the existance of the topic: cmd.CommandText = "select count(*) from TestCases where testCaseId = '" + testCaseId + "' "; int count = Convert.ToInt32(cmd.ExecuteScalar()); if (count > 0)//if count > 0, then the project ID exists in DB. { cmd.CommandText = "select testCase_createdBy from TestCases where testCaseId = '" + testCaseId + "' "; string actual_creatorId = cmd.ExecuteScalar().ToString(); cmd.CommandText = "select testCase_isDeleted from TestCases where testCaseId = '" + testCaseId + "' "; int isDeleted = Convert.ToInt32(cmd.ExecuteScalar()); if (isDeleted == 1) { correct = false; } } else { correct = false; // means that the project ID does not exists in DB. } connect.Close(); } return(correct); }
protected void Page_Load(object sender, EventArgs e) { initialPageAccess(); CheckErrors check = new CheckErrors(); try { if (!check.checkProjectAccess(projectId, loginId)) { goBack(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); goBack(); } printInfo(); }
protected void Page_Load(object sender, EventArgs e) { initialAccess(); CheckErrors check = new CheckErrors(); try { projectId = Request.QueryString["projectId"]; if (!check.checkProjectAccess(projectId, loginId)) { goBack(); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); goBack(); } //Check if the user editing is the master of this project or an admin: if (!isAccessAllowed()) { goBack(); } if (!IsPostBack) { files = new List <HttpPostedFile>(); //calStartDate.SelectedDate = DateTime.Today; fileNames.InnerHtml = " "; try { fillInputs(); } catch (Exception ex) { Console.WriteLine("Error: " + ex); } } }
public void SimpleMask3() { string mask = "Content~'Как же всё сложно'"; Assert.AreEqual(true, CheckErrors.isMaskInRightFormat(mask)); }
public void SimpleMask1() { string mask = "Name='qwer'"; Assert.AreEqual(true, CheckErrors.isMaskInRightFormat(mask)); }
public void WrongSimpleMask1() { string mask = "Name = 'wrong.txt'"; Assert.AreEqual(false, CheckErrors.isMaskInRightFormat(mask)); }
public void SimpleMask4() { string mask = "10<Length<=15'"; Assert.AreEqual(true, CheckErrors.isMaskInRightFormat(mask)); }
public void WrongSimpleMask2() { string mask = "Length= 15"; Assert.AreEqual(false, CheckErrors.isMaskInRightFormat(mask)); }
protected bool checkInputs() { bool correct = true; CheckErrors errors = new CheckErrors(); string a1, a2, a3; if (drpQ1.SelectedIndex == 0) { correct = false; lblQ1Error.Visible = true; lblQ1Error.Text = "Invalid input: Please select a question"; drpQ1.Focus(); } if (drpQ2.SelectedIndex == 0) { correct = false; lblQ2Error.Visible = true; lblQ2Error.Text = "Invalid input: Please select a question"; drpQ2.Focus(); } if (drpQ3.SelectedIndex == 0) { correct = false; lblQ3Error.Visible = true; lblQ3Error.Text = "Invalid input: Please select a question"; drpQ3.Focus(); } if (!errors.validAnswer(txtA1.Text, out a1)) { correct = false; lblA1Error.Visible = true; lblA1Error.Text = a1; txtA1.Focus(); } if (!errors.validAnswer(txtA2.Text, out a2)) { correct = false; lblA2Error.Visible = true; lblA2Error.Text = a2; txtA2.Focus(); } if (!errors.validAnswer(txtA3.Text, out a3)) { correct = false; lblA3Error.Visible = true; lblA3Error.Text = a3; txtA3.Focus(); } //Check specific questions if they are selected: if (drpQ1.SelectedValue.Equals("In what year were you born?") || drpQ1.SelectedValue.Equals("Which year did you graduate from high school?") || drpQ1.SelectedValue.Equals("In which year your immediate elder sibling was born?") || drpQ1.SelectedValue.Equals("In which year your immediate younger sibling was born?") || drpQ1.SelectedValue.Equals("What are the last four digits of your current phone number?") || drpQ1.SelectedValue.Equals("When did you graduate from the bachelor school?")) { if (!txtA1.Text.All(char.IsDigit) || txtA1.Text.Length != 4) { correct = false; lblA1Error.Visible = true; lblA1Error.Text = "The answer must be a four-digits."; txtA1.Focus(); } } if (drpQ2.SelectedValue.Equals("In what year were you born?") || drpQ2.SelectedValue.Equals("Which year did you graduate from high school?") || drpQ2.SelectedValue.Equals("In which year your immediate elder sibling was born?") || drpQ2.SelectedValue.Equals("In which year your immediate younger sibling was born?") || drpQ2.SelectedValue.Equals("What are the last four digits of your current phone number?") || drpQ2.SelectedValue.Equals("When did you graduate from the bachelor school?")) { if (!txtA2.Text.All(char.IsDigit) || txtA2.Text.Length != 4) { correct = false; lblA2Error.Visible = true; lblA2Error.Text = "The answer must be a four-digits."; txtA2.Focus(); } } if (drpQ3.SelectedValue.Equals("In what year were you born?") || drpQ3.SelectedValue.Equals("Which year did you graduate from high school?") || drpQ3.SelectedValue.Equals("In which year your immediate elder sibling was born?") || drpQ3.SelectedValue.Equals("In which year your immediate younger sibling was born?") || drpQ3.SelectedValue.Equals("What are the last four digits of your current phone number?") || drpQ3.SelectedValue.Equals("When did you graduate from the bachelor school?")) { if (!txtA3.Text.All(char.IsDigit) || txtA3.Text.Length != 4) { correct = false; lblA3Error.Visible = true; lblA3Error.Text = "The answer must be a four-digits."; txtA3.Focus(); } } if (drpQ1.SelectedValue.Equals("What was your birth month and date?")) { if (!txtA1.Text.All(char.IsDigit) || txtA1.Text.Length != 4) { correct = false; lblA1Error.Visible = true; lblA1Error.Text = "The answer must be four-digits, 2-digits month and 2-digits year."; txtA1.Focus(); } } if (drpQ2.SelectedValue.Equals("What was your birth month and date?")) { if (!txtA2.Text.All(char.IsDigit) || txtA2.Text.Length != 4) { correct = false; lblA2Error.Visible = true; lblA2Error.Text = "The answer must be four-digits, 2-digits month and 2-digits year."; txtA2.Focus(); } } if (drpQ3.SelectedValue.Equals("What was your birth month and date?")) { if (!txtA3.Text.All(char.IsDigit) || txtA3.Text.Length != 4) { correct = false; lblA3Error.Visible = true; lblA3Error.Text = "The answer must be four-digits, 2-digits month and 2-digits year."; txtA3.Focus(); } } return(correct); }
public void ComplexMask1() { string mask = "^(Name='qwer.txt')&(Length=13)"; Assert.AreEqual(true, CheckErrors.isMaskInRightFormat(mask)); }
public void ComplexMask2() { string mask = "(Name='qwer.txt')^(Content~'qqw')"; Assert.AreEqual(true, CheckErrors.isMaskInRightFormat(mask)); }
protected bool checkEditShortProfileInformationInput() { bool correct = true; //Hide everything first: lblFirstnameError.Visible = false; lblLastnameError.Visible = false; lblRaceError.Visible = false; lblGenderError.Visible = false; lblBirthdateError.Visible = false; lblNationalityError.Visible = false; lblIsPrivateError.Visible = false; CheckErrors check = new CheckErrors(); if (!check.validFirstName(txtFirstname.Text, out string firstnameError)) { correct = false; lblFirstnameError.Text = firstnameError; lblFirstnameError.Visible = true; } if (!check.validLastName(txtLastname.Text, out string lastnameError)) { correct = false; lblLastnameError.Text = lastnameError; lblLastnameError.Visible = true; } if (drpRace.SelectedIndex == 0) { correct = false; lblRaceError.Text = "Invalid input: Please select a race."; lblRaceError.Visible = true; } if (drpGender.SelectedIndex == 0) { correct = false; lblGenderError.Text = "Invalid input: Please select a gender."; lblGenderError.Visible = true; } string str_minimum_date = "1880-01-01"; DateTime minimum_date = DateTime.ParseExact(str_minimum_date, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (calBirthdate.SelectedDate == DateTime.MinValue) { correct = false; lblBirthdateError.Text = "Invalid input: Please select your birthdate."; lblBirthdateError.Visible = true; } else if (calBirthdate.SelectedDate < minimum_date || calBirthdate.SelectedDate >= DateTime.Now) { correct = false; lblBirthdateError.Text = "Invalid input: Please select a reasonable birthdate."; lblBirthdateError.Visible = true; } if (drpNationality.SelectedIndex == 0) { correct = false; lblNationalityError.Text = "Invalid input: Please select your nationality."; lblNationalityError.Visible = true; } if (drpIsPrivate.SelectedIndex == 0) { correct = false; lblIsPrivateError.Text = "Invalid input: Please select a permission."; lblIsPrivateError.Visible = true; } return(correct); }
protected void Page_Load(object sender, EventArgs e) { Configuration config = new Configuration(); conn = config.getConnectionString(); connect = new SqlConnection(conn); getSession(); //Get from and to pages: string current_page = "", previous_page = ""; if (HttpContext.Current.Request.Url.AbsoluteUri != null) { current_page = HttpContext.Current.Request.Url.AbsoluteUri; } if (Request.UrlReferrer != null) { previous_page = Request.UrlReferrer.ToString(); } //Get current time: DateTime currentTime = DateTime.Now; //Get user's IP: string userIP = GetIPAddress(); CheckAdminSession session = new CheckAdminSession(); bool correctSession = session.sessionIsCorrect(username, roleId, token, current_page, previous_page, currentTime, userIP); if (!correctSession) { clearSession(); } topicId = Request.QueryString["id"]; CheckErrors check = new CheckErrors(); if (!check.isDigit(topicId)) { goBack(); } int pageNum = Convert.ToInt32(Request.QueryString["page"]); bool topicApproved = isTopicApproved(); if (!topicApproved) { topicNotApproved(); } bool authorized = isUserAuthorizedToView(); if (!authorized) { unauthorized(); } showInformation(pageNum); checkIfTerminated(); checkIfDeleted(); if (!IsPostBack) { if (!requestedRemoveTopic && !requestedRemoveMessage && !requestedReportMessage) { if (HttpContext.Current.Request.Url.AbsoluteUri != null) { currentPage = HttpContext.Current.Request.Url.AbsoluteUri; } else { currentPage = "Home.aspx"; } if (Request.UrlReferrer != null) { previousPage = Request.UrlReferrer.ToString(); } else { previousPage = "Home.aspx"; } if (currentPage.Equals(previousPage)) { previousPage = "Home.aspx"; } } } }
public void SimpleMask2() { string mask = "Length=10g"; Assert.AreEqual(true, CheckErrors.isMaskInRightFormat(mask)); }