protected void Page_Load(object sender, EventArgs e) { if (Session["loggedIn"] == null) { Response.Redirect(ResolveUrl("~/Login.aspx")); } int user_type = Convert.ToInt32(Session["type"]); if (user_type == 2) //normal user dont allow { Response.Redirect(ResolveUrl("~/Main.aspx")); } SqlDataReader reader = SqlUtil.ExecuteReader("SELECT *, User_Main.Fname, User_Main.Lname FROM Moderation" + " INNER JOIN User_Main ON User_Main.ID_Num = Moderation.ID_Num"); while (reader.Read()) { Report report = new Report(); report.id = Guid.Parse(reader["Id"].ToString()); report.post_id = Guid.Parse(reader["PostId"].ToString()); report.post_type = Convert.ToInt32(reader["Type"]); switch (report.post_type) { case 0: report.post_type_str = "Gallery"; report.link = "~/Gallery/Main.aspx"; break; case 1: report.post_type_str = "Board"; report.link = "~/Board/View/" + report.post_id; break; case 2: report.post_type_str = "Blog"; report.link = "~/Blog/View/" + report.post_id; break; case 3: report.post_type_str = "Intern"; report.link = "~/Intern/Main.aspx"; break; case 4: report.post_type_str = "Connect"; report.link = "~/Connect/Main.aspx"; break; } report.reporter_id = Guid.Parse(reader["ID_Num"].ToString()); report.reporter_name = reader["Fname"] + " " + reader["Lname"]; report.date = DateTime.Parse(reader["Date"].ToString()); report.comment = reader["Comment"].ToString(); report.status = Convert.ToInt32(reader["Mod_Status"].ToString()); reports.Add(report); } reader.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["loggedIn"] == null) { Response.Redirect("Login.aspx"); } if (!IsPostBack) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("uid", Session["uid"])); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT * FROM User_Main WHERE ID_Num = @uid", parameters); if (!reader.Read()) //this should never happen { Response.Redirect("Main.aspx"); reader.Close(); return; } Uid.Text = reader["ID_Num"].ToString(); FirstName.Text = reader["Fname"].ToString(); LastName.Text = reader["Lname"].ToString(); Major.Text = reader["Major"].ToString(); Classification.SelectedValue = reader["Classification"].ToString(); Phone.Text = reader["Phone"].ToString(); OrgAffiliation.Text = reader["Org_Affiliation"].ToString(); reader.Close(); Password.Text = ""; NewPassword.Text = ""; NewPassword2.Text = ""; } }
protected void SecuritySubmit_Click(object sender, EventArgs e) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("uid", Session["uid"])); parameters.Add(new SqlParameter("password", Password.Text)); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT * FROM User_Main WHERE Password = @password AND ID_NUM = @uid", parameters); if (!reader.Read()) { Error.Text = "Incorrect password."; reader.Close(); return; } reader.Close(); parameters.Clear(); parameters.Add(new SqlParameter("password", NewPassword.Text)); parameters.Add(new SqlParameter("uid", Session["uid"])); SqlUtil.ExecuteNonQuery("UPDATE User_Main SET Password = @password WHERE ID_Num = @uid", parameters); Password.Text = ""; NewPassword.Text = ""; NewPassword2.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT TOP 50 *, User_Main.Fname, User_Main.Lname FROM Blog_Post" + " INNER JOIN User_Main ON User_Main.ID_Num = Blog_Post.ID_Num"); while (reader.Read()) { BlogPost post = new BlogPost(); post.blogID = Guid.Parse(reader["BlogID"].ToString()); post.author_uid = Guid.Parse(reader["ID_Num"].ToString()); post.author_name = reader["Fname"] + " " + reader["Lname"]; post.title = reader["Title"].ToString(); post.body = reader["Body"].ToString(); posts.Add(post); } reader.Close(); /* * if (Session["loggedIn"] != null) * { * SqlDataReader r = SqlUtil.ExecuteReader("SELECT * FROM Blog_Post"); * while (r.Read()) * { * BlogPost post = new BlogPost(); * post.blogID = Guid.Parse(reader["BlogID"].ToString()); * post.author_uid = Guid.Parse(reader["ID_Num"].ToString()); * post.title = reader["Title"].ToString(); * post.body = reader["Body"].ToString(); * follow_posts.Add(post); * } * r.Close(); * } */ }
void build_data() { string query = "select * from [Board_Post]"; SqlDataReader reader = SqlUtil.ExecuteReader(query); List <data_row> all_rows = new List <data_row>(); string board = ""; while (reader.Read()) { if (reader.GetByte(4) == 0) { board = "gives_board"; } else if (reader.GetByte(4) == 1) { board = "project_board"; } else if (reader.GetByte(4) == 2) { board = "poll_board"; } all_rows.Add(new data_row(board, reader.GetString(2), reader.GetDateTime(5), (Guid)reader["BpostID"])); } reader.Close(); convert_rows_to_string_and_publish(ref all_rows); }
protected Boolean has_voted() { List <SqlParameter> p = new List <SqlParameter>(); p.Add(new SqlParameter("@post_id", post_id)); p.Add(new SqlParameter("uid", (Guid)Session["uid"])); SqlDataReader reader = SqlUtil.ExecuteReader("select * from [poll_options] inner join [votes] on [poll_options].Option_ID=[Votes].Option_ID where [poll_options].BpostID=@post_id and [votes].ID_Num=@uid", p); while (reader.Read()) { Boolean report; if (reader.GetValue(0) != null) { report = true; reader.Close(); } else { report = false; reader.Close(); } return(report); } reader.Close(); return(false); }
protected void submit_Click(object sender, EventArgs e) { Error.Text = ""; List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@email", email.Text)); parameters.Add(new SqlParameter("@password", password.Text)); //TODO: hash the password SqlDataReader reader = SqlUtil.ExecuteReader("SELECT ID_Num, User_Type FROM User_Main WHERE Email = @email AND Password = @password", parameters); if (reader.Read()) { Guid uid = (Guid)reader["ID_Num"]; int type = reader.GetByte(1); Session.Add("uid", uid); Session.Add("type", type); Session.Add("loggedIn", true); reader.Close(); Response.Redirect("Main.aspx"); } else { Error.Text = "A user with that email and password combination does not exist."; } reader.Close(); }
protected void submit_Click(object sender, EventArgs e) { Error.Text = ""; List <SqlParameter> check_parameters = new List <SqlParameter>(); check_parameters.Add(new SqlParameter("@email", email.Text)); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT * FROM User_Main WHERE Email = @email", check_parameters); if (reader.Read()) { Error.Text = "A user with that email alreader exists."; reader.Close(); return; } reader.Close(); List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@email", email.Text)); parameters.Add(new SqlParameter("@fname", fname.Text)); parameters.Add(new SqlParameter("@lname", lname.Text)); parameters.Add(new SqlParameter("@password", password.Text)); int rows = SqlUtil.ExecuteNonQuery("INSERT INTO User_Main (Email, User_Type, Fname, Lname, Last_Login, Password) VALUES (@email, 2, @fname, @lname, GETDATE(), @password)", parameters); if (rows == 1) { Response.Redirect("Main.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { IList <string> segments = Request.GetFriendlyUrlSegments(); if (!Guid.TryParse(segments[0], out blogID)) { Response.Redirect(ResolveUrl("PostNotFound.aspx")); } List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("blogid", blogID)); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT Blog_Post.*, User_Main.Fname, User_Main.Lname FROM Blog_Post" + " INNER JOIN User_Main ON Blog_Post.ID_Num = User_Main.ID_Num" + " WHERE BlogID = @blogid", parameters); if (!reader.Read()) { reader.Close(); Response.Redirect("PostNotFound.aspx"); return; } title = reader["Title"].ToString(); body = reader["Body"].ToString(); author_name = reader["Fname"] + " " + reader["Lname"]; author_uid = Guid.Parse(reader["ID_Num"].ToString()); date = DateTime.Parse(reader["Date"].ToString()); if (Session["uid"] != null) { if (Session["uid"].ToString() == reader["ID_Num"].ToString()) { author = true; } } reader.Close(); parameters.Clear(); parameters.Add(new SqlParameter("blogid", blogID)); SqlDataReader r = SqlUtil.ExecuteReader("SELECT * FROM Post_Comment WHERE BlogID = @blogid", parameters); while (r.Read()) { Comment comment = new Comment(); comment.name = r["Name"].ToString(); comment.comment = r["Comment"].ToString(); comments.Add(comment); } r.Close(); }
protected void majorCDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT Major FROM Job_Posting"); while (reader.Read()) { string major = reader["Major"].ToString(); majorCDrop.Items.Add(new ListItem(major, major)); } reader.Close(); }
protected void cityCDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT City FROM Job_Posting"); while (reader.Read()) { string city = reader["City"].ToString(); cityCDrop.Items.Add(new ListItem(city, city)); } reader.Close(); }
protected void termDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT Term FROM Intern_Posting"); while (reader.Read()) { string term = reader["Term"].ToString(); termDrop.Items.Add(new ListItem(term, term)); } reader.Close(); }
protected void companyDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT Company FROM Intern_Posting"); while (reader.Read()) { string company = reader["Company"].ToString(); companyDrop.Items.Add(new ListItem(company, company)); } reader.Close(); }
protected void collegeCDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT College FROM Job_Posting"); while (reader.Read()) { string college = reader["College"].ToString(); collegeCDrop.Items.Add(new ListItem(college, college)); } reader.Close(); }
protected void positionCDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT Position FROM Job_Posting"); while (reader.Read()) { string position = reader["Position"].ToString(); positionCDrop.Items.Add(new ListItem(position, position)); } reader.Close(); }
protected void stateCDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT State FROM Job_Posting"); while (reader.Read()) { string state = reader["State"].ToString(); stateCDrop.Items.Add(new ListItem(state, state)); } reader.Close(); }
protected void classificationDrop_Load(object sender, EventArgs e) { SqlDataReader reader = SqlUtil.ExecuteReader("SELECT DISTINCT Classification FROM Intern_Posting"); while (reader.Read()) { string classification = reader["Classification"].ToString(); classificationDrop.Items.Add(new ListItem(classification, classification)); } reader.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <SqlParameter> parameters = new List <SqlParameter>(); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT College FROM Intern_Posting", parameters); collegedrop.Items.Insert(0, new ListItem("Pick a college", "0")); collegedrop.SelectedIndex = 0; while (reader.Read()) { string college = reader["College"].ToString(); collegedrop.Items.Add(new ListItem(college, college)); } reader.Close(); } }
string build_data() { // built for testing purposes. Soon will be rewritten for to read the database and build a data structure from it. string test_string = ""; string query = "select schema_name(t.schema_id) as schema_name, t.name as table_name, t.create_date, t.modify_date from sys.tables t order by schema_name, table_name; "; SqlDataReader reader = SqlUtil.ExecuteReader(query); int i = 0; while (reader.Read()) { test_string += reader.GetString(0); i++; } reader.Close(); return(test_string); //placeholder for reading database }
protected void Page_Load(object sender, EventArgs e) { IList <string> segments = Request.GetFriendlyUrlSegments(); id = segments[0]; if (!IsPostBack) { List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("id", id)); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT * FROM Moderation WHERE Id = @id", parameters); if (!reader.Read()) { Response.Redirect("Main.aspx"); } ModStatus.SelectedIndex = Convert.ToInt32(reader["Mod_Status"]); PostId.Text = reader["Id"].ToString(); reader.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["loggedIn"] == null) { Response.Redirect(ResolveUrl("~/Login.aspx")); } IList <string> segments = Request.GetFriendlyUrlSegments(); blogID = segments[0]; if (!IsPostBack) { Guid id; if (!Guid.TryParse(blogID, out id)) { Response.Redirect(ResolveUrl("PostNotFound.aspx")); } List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("blogid", blogID)); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT * FROM Blog_Post WHERE BlogID = @blogid", parameters); if (!reader.Read()) { Response.Redirect(ResolveUrl("PostNotFound.aspx")); } if (Session["uid"].ToString() != reader["ID_Num"].ToString()) { reader.Close(); Response.Redirect("Main.aspx"); } title.Text = reader["Title"].ToString(); Body.Text = reader["Body"].ToString(); reader.Close(); } }
protected void Page_Load(object sender, EventArgs e) { require_login(); IList <string> seg = Request.GetFriendlyUrlSegments(); if (!Guid.TryParse(seg[0], out post_id)) { Response.Redirect("/Board/404.aspx"); } List <SqlParameter> p = new List <SqlParameter>(); p.Add(new SqlParameter("@post_id", post_id)); SqlDataReader reader = SqlUtil.ExecuteReader("select * from board_post where BpostID=@post_id", p); if (!reader.Read()) { reader.Close(); Response.Redirect("404.aspx"); return; } Byte[] bytes = (Byte[])reader["Attachments"]; view_title.Text = (string)reader["Title"]; board = (byte)reader["Board"]; view_description.Text = (string)reader["Description"]; if (bytes.Length > 0) { string str = Convert.ToBase64String(bytes, 0, bytes.Length); view_image.ImageUrl = "data:image/png;base64," + str; view_image.Visible = true; view_image_label.Visible = true; } reader.Close(); if (board == 2) { p.Clear(); p.Add(new SqlParameter("@post_id", post_id)); SqlDataReader reader2 = SqlUtil.ExecuteReader("select * from poll_options where BpostID=@post_id", p); option_list = new List <string>(); id_list = new List <Guid>(); int i = 0; while (reader2.Read()) { option_list.Add(reader2.GetString(2)); id_list.Add(reader2.GetGuid(0)); i++; } while (i < 10) { option_list.Add(""); i++;//good fix for bad code } reader2.Close(); build_poll_radios(); } }
protected void build_poll_radios() { List <SqlParameter> p = new List <SqlParameter>(); List <double> votes = new List <double>(); int i = 0; foreach (Guid op in id_list) { if (option_list[i] != "") { p.Clear(); p.Add(new SqlParameter("@option_id", op)); SqlDataReader reader = SqlUtil.ExecuteReader("select * from Votes where Option_ID=@option_id", p); DataTable dt = new DataTable(); dt.Load(reader); reader.Close(); votes.Add(dt.Rows.Count); } i++; } if (!has_voted()) { if (option_list[0] != "") { option1.Text = option_list[0]; option1.Visible = true; } if (option_list[1] != "") { option2.Text = option_list[1]; option2.Visible = true; } if (option_list[2] != "") { option3.Text = option_list[2]; option3.Visible = true; } if (option_list[3] != "") { option4.Text = option_list[3]; option4.Visible = true; } if (option_list[4] != "") { option5.Text = option_list[4]; option5.Visible = true; } if (option_list[5] != "") { option6.Text = option_list[5]; option6.Visible = true; } if (option_list[6] != "") { option7.Text = option_list[6]; option7.Visible = true; } if (option_list[7] != "") { option8.Text = option_list[7]; option8.Visible = true; } if (option_list[8] != "") { option9.Text = option_list[8]; option9.Visible = true; } if (option_list[9] != "") { option10.Text = option_list[9]; option10.Visible = true; } submit_vote.Visible = true; } else { double total = 0; foreach (double vo in votes) { total += vo; } int j = 0; if (option_list[j] != "") { poll_option_desc1.Visible = true; poll_option_desc1.Text = " " + option_list[j]; poll_option_percent1.Visible = true; if (total > 0) { poll_option_percent1.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent1.Text = "0%"; } poll_option_votes1.Visible = true; poll_option_votes1.Text = votes[j].ToString() + " Votes"; poll_option_bar1.Visible = true; if (total > 0) { poll_option_bar1.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar1.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc2.Visible = true; poll_option_desc2.Text = " " + option_list[j]; poll_option_percent2.Visible = true; if (total > 0) { poll_option_percent2.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent2.Text = "0%"; } poll_option_votes2.Visible = true; poll_option_votes2.Text = votes[j].ToString() + " Votes"; poll_option_bar2.Visible = true; if (total > 0) { poll_option_bar2.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar2.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc3.Visible = true; poll_option_desc3.Text = " " + option_list[j]; poll_option_percent3.Visible = true; if (total > 0) { poll_option_percent3.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent3.Text = "0%"; } poll_option_votes3.Visible = true; poll_option_votes3.Text = votes[j].ToString() + " Votes"; poll_option_bar3.Visible = true; if (total > 0) { poll_option_bar3.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar3.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc4.Visible = true; poll_option_desc4.Text = " " + option_list[j]; poll_option_percent4.Visible = true; if (total > 0) { poll_option_percent4.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent4.Text = "0%"; } poll_option_votes4.Visible = true; poll_option_votes4.Text = votes[j].ToString() + " Votes"; poll_option_bar4.Visible = true; if (total > 0) { poll_option_bar4.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar4.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc5.Visible = true; poll_option_desc5.Text = " " + option_list[j]; poll_option_percent5.Visible = true; if (total > 0) { poll_option_percent5.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent5.Text = "0%"; } poll_option_votes5.Visible = true; poll_option_votes5.Text = votes[j].ToString() + " Votes"; poll_option_bar5.Visible = true; if (total > 0) { poll_option_bar5.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar5.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc6.Visible = true; poll_option_desc6.Text = " " + option_list[j]; poll_option_percent6.Visible = true; if (total > 0) { poll_option_percent6.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent6.Text = "0%"; } poll_option_votes6.Visible = true; poll_option_votes6.Text = votes[j].ToString() + " Votes"; poll_option_bar6.Visible = true; if (total > 0) { poll_option_bar6.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar6.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc7.Visible = true; poll_option_desc7.Text = " " + option_list[j]; poll_option_percent7.Visible = true; if (total > 0) { poll_option_percent7.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent7.Text = "0%"; } poll_option_votes7.Visible = true; poll_option_votes7.Text = votes[j].ToString() + " Votes"; poll_option_bar7.Visible = true; if (total > 0) { poll_option_bar7.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar7.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc8.Visible = true; poll_option_desc8.Text = " " + option_list[j]; poll_option_percent8.Visible = true; if (total > 0) { poll_option_percent8.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent8.Text = "0%"; } poll_option_votes8.Visible = true; poll_option_votes8.Text = votes[j].ToString() + " Votes"; poll_option_bar8.Visible = true; if (total > 0) { poll_option_bar8.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar8.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc9.Visible = true; poll_option_desc9.Text = " " + option_list[j]; poll_option_percent9.Visible = true; if (total > 0) { poll_option_percent9.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent9.Text = "0%"; } poll_option_votes9.Visible = true; poll_option_votes9.Text = votes[j].ToString() + " Votes"; poll_option_bar9.Visible = true; if (total > 0) { poll_option_bar9.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar9.Style.Add("width", "0%"); } j++; } if (option_list[j] != "") { poll_option_desc10.Visible = true; poll_option_desc10.Text = " " + option_list[j]; poll_option_percent10.Visible = true; if (total > 0) { poll_option_percent10.Text = " " + Math.Round(((votes[j] / total)) * 100).ToString() + "%"; } else { poll_option_percent10.Text = "0%"; } poll_option_votes10.Visible = true; poll_option_votes10.Text = votes[j].ToString() + " Votes"; poll_option_bar10.Visible = true; if (total > 0) { poll_option_bar10.Style.Add("width", (((votes[j] / total) * 100).ToString() + "%")); } else { poll_option_bar10.Style.Add("width", "0%"); } j++; } } }
public static bool Prefix(ref RunAggregateDatas __result, ref string database, ref string userId, ref string altUserId, ref int page, ref int numPerPage, ref HadesNetworkCaller.SortFieldName sortFieldName, ref HadesNetworkCaller.SortDirection sortDirection) { // Get the filter manager. I don't think there's a way to pass this as an argument, so we'll have to // set it manually. FilterManager manager = AdvancedRunHistory.filterManager; // This is just vanilla code. altUserId = altUserId ?? string.Empty; int environment = (int)AppManager.EnvironmentConfig.Environment; string commandText = string.Format("SELECT {0} FROM '{1}' WHERE ({2} = '{3}' OR {4} = '{5}') AND {6} = {7} ORDER BY {8} {9}", "runId", "runHistoryTable", "userId", userId, "userId", altUserId, "env", environment, sortFieldName, sortDirection); List <string> runIds = new List <string>(); if (!SqlUtil.ExecuteReader(database, commandText, ErrorFile.RunMinDbEntry, 3, delegate(SqliteDataReader reader) { while (reader.Read()) { runIds.Add(reader.GetString(0)); } return(true); }, exactlyOneRead: false)) { __result = null; return(false); } // The actual patch; start by assuming we don't want to filter. List <string> filteredRunIds = runIds; // Only filter runs if the manager is active- if (manager.Active) { // Make a new list of runIds. filteredRunIds = new List <String>(); // Go through all runIds in the original list. foreach (string runId in runIds) { // Try to read the run from the DB. RunMinDbEntry runMinDbEntry = RunMinDbEntry.ReadFromDb(database, runId); if (runMinDbEntry != null) { // Create a RunAggregateData. Assume it's eglibile. RunAggregateData runAggregateData = runMinDbEntry.minimalRunData.CreateRunAggregateData(); bool isEgligible = true; // Go through all filters and make the run uneglibile if it doesn't pass. foreach (IRunDataFilter filter in manager.Filters) { if (!filter.IsEgligible(runAggregateData)) { isEgligible = false; break; } } // The run has passed all filters, add it to the filtered list. if (isEgligible) { filteredRunIds.Add(runId); } } } } // Back to vanilla code, but changing runIds --> filteredRunIds. List <string> list = new List <string>(); List <RunAggregateData> list2 = new List <RunAggregateData>(); for (int i = (page - 1) * numPerPage; i < filteredRunIds.Count; i++) { if (list2.Count >= numPerPage) { break; } RunMinDbEntry runMinDbEntry = RunMinDbEntry.ReadFromDb(database, filteredRunIds[i]); if (runMinDbEntry != null) { RunAggregateData runAggregateData = runMinDbEntry.minimalRunData.CreateRunAggregateData(); string item = JsonUtility.ToJson(runAggregateData); list.Add(item); list2.Add(runAggregateData); } } int pageCount = filteredRunIds.Count / numPerPage + Math.Min(filteredRunIds.Count % numPerPage, 1); RunAggregateDatas runAggregateDatas = new RunAggregateDatas(list.ToArray(), pageCount, page); runAggregateDatas.SetRuns(list2.ToArray()); __result = runAggregateDatas; return(false); }
protected void Page_Load(object sender, EventArgs e) { IList <string> segments = Request.GetFriendlyUrlSegments(); uid = segments[0]; Guid id; if (!Guid.TryParse(uid, out id)) { Response.Redirect(ResolveUrl("UserNotFound.aspx")); } List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("uid", uid)); SqlDataReader reader = SqlUtil.ExecuteReader("SELECT Fname, Lname FROM User_Main WHERE ID_Num = @uid", parameters); if (!reader.Read()) { reader.Close(); Response.Redirect(ResolveUrl("UserNotFound.aspx")); } name = reader["Fname"] + " " + reader["Lname"]; reader.Close(); parameters.Clear(); parameters.Add(new SqlParameter("uid", uid)); SqlDataReader r = SqlUtil.ExecuteReader("SELECT * FROM Blog_Post WHERE ID_Num = @uid", parameters); while (r.Read()) { BlogPost post = new BlogPost(); post.blogID = Guid.Parse(r["BlogID"].ToString()); post.title = r["Title"].ToString(); post.body = r["Body"].ToString(); posts.Add(post); } r.Close(); parameters.Clear(); parameters.Add(new SqlParameter("@uid", uid)); r = SqlUtil.ExecuteReader("SELECT *, User_Main.Fname, User_Main.Lname, User_Main.ID_Num FROM BlogFollowers" + " INNER JOIN User_Main ON BlogFollowers.Follower = User_Main.ID_Num" + " WHERE Following = @uid", parameters); while (r.Read()) { UserProfile user = new UserProfile(); user.name = r["Fname"] + " " + r["Lname"]; user.uid = Guid.Parse(r["ID_Num"].ToString()); following.Add(user); } r.Close(); parameters.Clear(); parameters.Add(new SqlParameter("@uid", uid)); r = SqlUtil.ExecuteReader("SELECT *, User_Main.Fname, User_Main.Lname, User_Main.ID_Num FROM BlogFollowers" + " INNER JOIN User_Main ON BlogFollowers.Following = User_Main.ID_Num" + " WHERE Follower = @uid", parameters); while (r.Read()) { UserProfile user = new UserProfile(); user.name = r["Fname"] + " " + r["Lname"]; user.uid = Guid.Parse(r["ID_Num"].ToString()); followers.Add(user); } r.Close(); if (Session["loggedIn"] != null) { parameters.Clear(); parameters.Add(new SqlParameter("profile_uid", uid)); parameters.Add(new SqlParameter("uid", Session["uid"])); r = SqlUtil.ExecuteReader("SELECT * FROM BlogFollowers WHERE Following = @profile_uid AND Follower = @uid", parameters); if (r.Read()) { followingUser = true; } r.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["loggedIn"] == null) //TODO: tell the user they need to login { Response.Redirect("../Login.aspx"); } else { if (!IsPostBack) { collegeCDrop.Items.Insert(0, new ListItem("Pick a college", "0")); collegeCDrop.SelectedIndex = 0; countryCDrop.Items.Insert(0, new ListItem("Pick a country", "0")); countryCDrop.SelectedIndex = 0; stateCDrop.Items.Insert(0, new ListItem("Pick a state", "0")); stateCDrop.SelectedIndex = 0; cityCDrop.Items.Insert(0, new ListItem("Pick a city", "0")); cityCDrop.SelectedIndex = 0; companyCDrop.Items.Insert(0, new ListItem("Pick a company", "0")); companyCDrop.SelectedIndex = 0; majorCDrop.Items.Insert(0, new ListItem("Pick a major", "0")); majorCDrop.SelectedIndex = 0; graduationCDrop.Items.Insert(0, new ListItem("Pick a position", "0")); graduationCDrop.SelectedIndex = 0; positionCDrop.Items.Insert(0, new ListItem("Pick a classification", "0")); positionCDrop.SelectedIndex = 0; SqlDataReader reader = SqlUtil.ExecuteReader("SELECT *, User_Main.Fname AS MFname, User_Main.Lname AS MLname FROM Job_Posting " + "LEFT JOIN User_Main ON Job_Posting.ID_Num = User_Main.ID_Num"); while (reader.Read()) { Connect view = new Connect(); view.major = reader["Major"].ToString(); view.name = reader["MFname"] + " " + reader["MLname"]; view.college = reader["College"].ToString(); view.position = reader["Position"].ToString(); view.graduation = reader["Graduation"].ToString(); view.company = reader["Company"].ToString(); view.location = reader["City"].ToString() + "," + reader["State"].ToString() + "," + reader["Country"].ToString(); view.long_desc = reader["Long_Disc"].ToString(); view.resources = reader["Resources_Used"].ToString(); view.lessons = reader["Lessons_Learned"].ToString(); view.image = reader["Image"].ToString(); view.facebook = reader["Facebook"].ToString(); view.twitter = reader["Twitter"].ToString(); view.email = reader["Email"].ToString(); view.linkedIn = reader["LinkedIn"].ToString(); view.instagram = reader["Instagram"].ToString(); view.id = reader["ID_Num"].ToString(); views.Add(view); } reader.Close(); } } }