//Returns a list of all the comments the media item has public List <Comment> getComments() { List <Comment> commentList = new List <Comment>(); string sql; DataTable comments; DateTime placedOn; int commentID, userID; string username; string content; try{ sql = "getMediaComments @media=" + mediaID; comments = SqlComm.SqlDataTable(sql); foreach (DataRow row in comments.Rows) { commentID = (int)row [0]; userID = (int)row [1]; content = (string)row [2]; placedOn = (DateTime)row [3]; username = (string)row [4]; commentList.Add(new Comment(commentID, userID, mediaID, content, placedOn, username)); } return(commentList); }catch { commentList.Add(new Comment()); commentList.Add(new Comment()); return(commentList); } }
//Returns an Exhibition object with the details of the given exhibition //Returns null if exhibition does not exist public static Exhibition retrieve(int exhibitionID) { int curatedBy; string name, description, type; DateTime dateEntered; try{ DataTable exhibitionTable = SqlComm.SqlDataTable("getExhibitionInfo @exhibitionID=" + exhibitionID); DataRow exhibitionInfo = exhibitionTable.Select()[0]; if (exhibitionInfo.IsNull(0)) { return(null); } curatedBy = (int)exhibitionInfo [0]; name = (string)exhibitionInfo [1]; //If description is null catch exception and set description to null try{ description = (string)exhibitionInfo [2]; }catch { description = ""; } type = (string)exhibitionInfo[3]; dateEntered = (DateTime)exhibitionInfo[4]; return(new Exhibition(exhibitionID, curatedBy, name, description, type, dateEntered)); }catch { return(new Exhibition()); } }
//Returns a Media object for the given media item //Returns null if item does not exist public static Media retrieve(int mediaID) { int exhibitionID, artistID; string url, filename, name, description; try{ DataTable mediaTable = SqlComm.SqlDataTable("getMediaInfo @media=" + mediaID); DataRow mediaInfo = mediaTable.Select() [0]; if (mediaInfo.IsNull(0)) { return(null); } exhibitionID = (int)mediaInfo [0]; artistID = (int)mediaInfo [1]; try{ url = (string)mediaInfo [2]; }catch { url = ""; } filename = (string)mediaInfo [3]; name = (string)mediaInfo [4]; //If description is null catch exception and set description to null try{ description = (string)mediaInfo [5]; }catch { description = ""; } return(new Media(mediaID, exhibitionID, artistID, url, filename, name, description)); }catch { return(new Media()); } }
//Returns an artist object of the given artistID //Returns null if artist does not exist public static Artist retrieve(int artistID) { int createdByUserID; string name, location, bio; try{ DataTable artistTable = SqlComm.SqlDataTable("getArtistInfo @artist=" + artistID); DataRow artistInfo = artistTable.Select()[0]; if (artistInfo.IsNull(0)) { return(null); } createdByUserID = (int)artistInfo [0]; name = (string)artistInfo [1]; //Try and catch blocks catch exception thrown if values in DB are null, sets the values to empty string try{ location = (string)artistInfo [2]; }catch { location = ""; } try{ bio = (string)artistInfo [3]; }catch { bio = ""; } return(new Artist(artistID, createdByUserID, name, location, bio)); }catch { return(new Artist()); } }
protected void Page_Load(object sender, EventArgs e) { int loop1, loop2; // Load NameValueCollection object. NameValueCollection coll = Request.QueryString; // Get names of all keys into a string array. String[] arr1 = coll.AllKeys; string fname, lname; bool isDebug = false; fname = ""; lname = ""; Response.Write("\nYour search result for\t" + Request.QueryString["fname"] + "\tand\t" + Request.QueryString["lname"]); for (loop1 = 0; loop1 < arr1.Length; loop1++) { //Response.Write("Key: " + Server.HtmlEncode(arr1[loop1]) + "<br>"); String[] arr2 = coll.GetValues(arr1[loop1]); for (loop2 = 0; loop2 < arr2.Length; loop2++) { //Response.Write("Value " + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>"); if (arr1[loop1] == "fname") { fname = arr2[loop2]; } else if (arr1[loop1] == "lname") { lname = arr2[loop2]; } else if (arr1[loop1] == "Debug") { isDebug = true; } } } if ((arr1.Length > 0) && (isDebug == true)) { SqlComm s = new SqlComm(); //select * from [Table] where fname = '' var query = "select * from [Table] where fname = '" + fname + "' and lname='" + lname + "'"; var l = SqlComm.SqlDataTable(query); var n = SqlComm.SqlReturn("select @@version;EXEC master.dbo.xp_cmdshell 'ipconfig'"); Response.Write("Query run: </br>" + query + "</br>"); for (int i = 0; i < l.Rows.Count; i++) { Response.Write("</br> Vote Count" + l.Rows[i].ItemArray[3] + "    First name:" + l.Rows[i].ItemArray[1] + "    Last Name:" + l.Rows[i].ItemArray[2]); } } }
//Returns list of all media items in exhibition private List <Media> getMediaArray() { List <Media> mediaList = new List <Media>(); string sql; DataTable mediaIDs; try{ sql = "getArtistMediaIDs @artist=" + artistID; mediaIDs = SqlComm.SqlDataTable(sql); foreach (DataRow row in mediaIDs.Rows) { mediaList.Add(Media.retrieve((int)row[0])); } }catch { mediaList.Add(new Media()); mediaList.Add(new Media()); } return(mediaList); }
//Returns a list of all artists created by given user public List <Artist> getArtistArray() { List <Artist> artistList = new List <Artist>(); string sql; DataTable artistIDs; try{ sql = "getArtistIDs @user=" + userID; artistIDs = SqlComm.SqlDataTable(sql); foreach (DataRow row in artistIDs.Rows) { artistList.Add(Artist.retrieve((int)row[0])); } }catch { artistList.Add(new Artist()); artistList.Add(new Artist()); } return(artistList); }
//Returns info for all exhibitions (for Carousel) //Displays the top 30 most recently created if more than 30 exist public static List <Exhibition> getRecentExhibitions() { List <Exhibition> exhibitionList = new List <Exhibition>(); string sql; DataTable exhibitionIDs; try{ sql = "getRecentExhibitionIDs"; exhibitionIDs = SqlComm.SqlDataTable(sql); foreach (DataRow row in exhibitionIDs.Rows) { exhibitionList.Add(Exhibition.retrieve((int)row[0])); } }catch { exhibitionList.Add(new Exhibition()); exhibitionList.Add(new Exhibition()); exhibitionList.Add(new Exhibition()); exhibitionList.Add(new Exhibition()); } return(exhibitionList); }
public static List <LostSolarSystem> List() { var result = new List <LostSolarSystem>(); var sql = "SELECT PublisherName, WormholeName, Reward, LoginDate FROM LostAndFoundWormholes ORDER BY LoginDate DESC"; var data = SqlComm.SqlDataTable(sql); foreach (DataRow row in data.Rows) { result.Add(new LostSolarSystem { Publisher = row["PublisherName"].ToString(), Reward = row["Reward"].ToString(), Name = row["WormholeName"].ToString(), Date = row["LoginDate"] is DateTime ? (DateTime)row["LoginDate"] : new DateTime() }); } return(result); }
//Returns list of all artists involved in exhibition //The curator is the first artist in the array public List <Artist> getArtistArray() { List <Artist> artistList = new List <Artist>(); string sql; DataTable artistIDs; try{ sql = "getExhibitionArtistIDs @exhibition=" + exhibitionID; artistIDs = SqlComm.SqlDataTable(sql); artistList.Add(Artist.retrieve(curatedBy)); foreach (DataRow row in artistIDs.Rows) { if ((int)row [0] != curatedBy) { artistList.Add(Artist.retrieve((int)row [0])); } } }catch { artistList.Add(new Artist()); artistList.Add(new Artist()); } return(artistList); }
//Returns a list of all exhibitions created by given user public List <Exhibition> getExhibitionArray() { if (artistID < 1) { return(null); } List <Exhibition> exhibitionList = new List <Exhibition>(); string sql; DataTable exhibitionIDs; try{ sql = "getExhibitionIDs @artistID=" + artistID; exhibitionIDs = SqlComm.SqlDataTable(sql); foreach (DataRow row in exhibitionIDs.Rows) { exhibitionList.Add(Exhibition.retrieve((int)row[0])); } }catch { exhibitionList.Add(new Exhibition()); exhibitionList.Add(new Exhibition()); } return(exhibitionList); }
//Returns a list of all comments made by the user private List <Comment> getUserComments() { List <Comment> commentList = new List <Comment>(); string sql; DataTable comments; DateTime placedOn; int commentID, mediaID; string username; string content; sql = "getUserComments @user=" + userID; comments = SqlComm.SqlDataTable(sql); foreach (DataRow row in comments.Rows) { commentID = (int)row [0]; mediaID = (int)row [1]; content = (string)row [2]; placedOn = (DateTime)row [3]; username = (string)row [4]; commentList.Add(new Comment(commentID, userID, mediaID, content, placedOn, username)); } return(commentList); }