protected void Page_Load(object sender, EventArgs e) { UserLbl.Text = (new LdapAuthentication(Context.User.Identity.Name.Split('\\')[0])). GetUserDisplayName(Context.User.Identity.Name.Split('\\')[1]); List<string> allowed = new List<string>{"lhuether", "slogsdon"}; if (allowed.Contains(Context.User.Identity.Name.Split('\\')[1])) { ListHyperLink.Visible = true; } }
protected bool ExecuteQuery(string query, Func<OleDbDataReader, List<DBItem>> callback = null) { bool rowsAffected = false; OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;" + "Data Source=" + Server.MapPath(_db)); //try //{ connection.Open(); using (OleDbCommand command = new OleDbCommand(query, connection)) { //try //{ if (query.Substring(0, 6) == "SELECT") { if (callback != null) { _dbItemList = callback.Invoke(command.ExecuteReader()); } rowsAffected = true; } else { rowsAffected = Convert.ToBoolean(command.ExecuteNonQuery()); } //} //catch (OleDbException e) //{ // Message.Text += "_dbItemList is null. " + e.Message + "\n"; //} } connection.Close(); //} //catch (OleDbException e) //{ // Message.Text += "_dbItemList is null. " + e.Message + "\n"; //} return rowsAffected; }
protected List<DBItem> GetSubmissionsQueryCallback(OleDbDataReader reader) { List<DBItem> returnList = new List<DBItem>(); if (reader.HasRows) { while (reader.Read()) { DBItem item = new DBItem(); item.ID = reader.GetInt32(reader.GetOrdinal("ID")); item.User = reader.GetString(reader.GetOrdinal("User")); item.DateTime = reader.GetDateTime(reader.GetOrdinal("DateTime")); item.Person = reader.GetString(reader.GetOrdinal("Person")); item.Rating = reader.GetString(reader.GetOrdinal("Rating")); item.Description = reader.GetString(reader.GetOrdinal("Description")); item.Votes = reader.GetString(reader.GetOrdinal("Votes")); returnList.Add(item); } } return returnList; }
protected List<DBItem> GetVotesQueryCallback(OleDbDataReader reader) { List<DBItem> returnList = new List<DBItem> { }; if (reader.HasRows) { while (reader.Read()) { DBItem item = new DBItem(); item.Votes = reader.GetString(reader.GetOrdinal("Votes")); returnList.Add(item); } } return returnList; }
public string stripNames(string text, string person) { string displayName = (new LdapAuthentication(Context.User.Identity.Name.Split('\\')[0])). GetUserDisplayName(person); List<string> excludes = new List<string>(); excludes.Add(person); foreach (string str in displayName.Split(' ')) { excludes.Add(str); excludes.Add(str.ToLower()); excludes.Add(str.ToLowerInvariant()); excludes.Add(str.ToUpper()); excludes.Add(str.ToUpperInvariant()); } foreach (string search in excludes) { text = ReplaceEx(text, person, "the employee"); } return text; }