// The Table getputs.item has the following schema: // getputs.item [IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, UpVotes, DownVotes, Spam] // The Table getputs.user has the following schema: // getputs.item [UID, Password, Date, EMail, About, Admin, Points] private void LoadItemDB(ProcessingEngine.Sort sortType) { List<Item> itemList = new List<Item>(); // SELECT * FROM item where IID = ( SELECT IID FROM saveditems where UID = 'vatsal'); // SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks FROM getputs.item WHERE IID = ( SELECT IID FROM saveditems WHERE UID = 'vatsal') ORDER BY DATE_FORMAT(Date, '%Y-%m-%d %k:%i:%S') DESC LIMIT 25; string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE IID IN ( SELECT IID FROM saveditems where UID = '" + UID + "') ORDER BY DATE_FORMAT(Date, '%Y-%m-%d %k:%i:%S') DESC LIMIT " + engine.MaxItems.ToString() + ";"; MySqlDataReader retList; retList = dbOps.ExecuteReader(queryString); if (retList != null && retList.HasRows) { while (retList.Read()) { Item item = new Item(); item.IID = Convert.ToInt32(retList["IID"]); item.Title = Convert.ToString(retList["Title"]); item.Link = Convert.ToString(retList["Link"]); item.Text = Convert.ToString(retList["Text"]); item.Date = Convert.ToString(retList["Date"]); item.UID = Convert.ToString(retList["UID"]); item.NComments = Convert.ToInt32(retList["NComments"]); item.Category = Convert.ToString(retList["Category"]); item.Clicks = Convert.ToInt32(retList["Clicks"]); item.NSaved = Convert.ToInt32(retList["NSaved"]); item.NEMailed = Convert.ToInt32(retList["NEMailed"]); item.TagString = Convert.ToString(retList["Tags"]); item.TagList = general.ConvertCSVToList(item.TagString); item.AvgRating = Convert.ToDouble(retList["AvgRating"]); item.NRated = Convert.ToInt32(retList["NRated"]); item.Age = item.GetAge(item.Date); // item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age); item.Marks = item.GetMarks(item); if (!string.IsNullOrEmpty(item.Link)) { item.Text = string.Empty; } itemList.Add(item); } retList.Close(); } if (sortType == ProcessingEngine.Sort.Hot) { itemList = engine.SortItems(itemList, sortType); } // LoadItemTable(itemList); ItemDisplayer.ShowItemsOptions itemOptions = ItemDisplayer.ShowItemsOptions.ShowUIDLink | ItemDisplayer.ShowItemsOptions.ShowTime | ItemDisplayer.ShowItemsOptions.ShowCategoryLink | ItemDisplayer.ShowItemsOptions.ShowEMailLink | ItemDisplayer.ShowItemsOptions.ShowCommentsLink | ItemDisplayer.ShowItemsOptions.ShowImage | ItemDisplayer.ShowItemsOptions.ShowRatings | ItemDisplayer.ShowItemsOptions.ShowTags | ItemDisplayer.ShowItemsOptions.CountClicks | ItemDisplayer.ShowItemsOptions.ShowPreviousNextLinks; string itemTable = itemDisplayer.LoadItemTable(itemList, itemOptions, itemLayoutOptions, startItem, UID, sort, links.SavedPageLink.Replace("~\\", "")); ItemDiv.InnerHtml = itemTable; }
private List<Item> LoadItemDB(ProcessingEngine.Sort sortType, List<string> preferredCategoriesList) { List<Item> itemList = new List<Item>(); string categoriesDBStr = string.Empty; // A categories string formatted for Database Retrieval. for (int i = 0; i < preferredCategoriesList.Count; i++) { if (i == preferredCategoriesList.Count - 1) { categoriesDBStr = categoriesDBStr + "'" + preferredCategoriesList[i] + "'"; } else { categoriesDBStr = categoriesDBStr + "'" + preferredCategoriesList[i] + "', "; } } // SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks FROM getputs.item WHERE Category IN ('startups', 'programming'); // string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks FROM item WHERE Category IN (" + categoriesDBStr + ");"; // string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE Spam = 0 AND (Tags LIKE '%" + tag + "," + "%' OR Tags LIKE '%" + "," + tag + "%' OR Tags LIKE '" + tag + "') ORDER BY IID DESC LIMIT " + engine.MaxItems.ToString() + ";"; string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE Spam = 0 AND Category IN (" + categoriesDBStr + ") ORDER BY DATE_FORMAT(Date, '%Y-%m-%d %k:%i:%S') DESC LIMIT " + engine.MaxItems.ToString() + ";"; MySqlDataReader retList; retList = dbOps.ExecuteReader(queryString); if (retList != null && retList.HasRows) { while (retList.Read()) { Item item = new Item(); item.IID = Convert.ToInt32(retList["IID"]); item.Title = Convert.ToString(retList["Title"]); item.Link = Convert.ToString(retList["Link"]); item.Text = Convert.ToString(retList["Text"]); item.Date = Convert.ToString(retList["Date"]); item.UID = Convert.ToString(retList["UID"]); item.NComments = Convert.ToInt32(retList["NComments"]); item.Category = Convert.ToString(retList["Category"]); item.Clicks = Convert.ToInt32(retList["Clicks"]); item.NSaved = Convert.ToInt32(retList["NSaved"]); item.NEMailed = Convert.ToInt32(retList["NEMailed"]); item.TagString = Convert.ToString(retList["Tags"]); item.TagList = general.ConvertCSVToList(item.TagString); item.AvgRating = Convert.ToDouble(retList["AvgRating"]); item.NRated = Convert.ToInt32(retList["NRated"]); item.Age = item.GetAge(item.Date); // item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age); item.Marks = item.GetMarks(item); if (!string.IsNullOrEmpty(item.Link)) { item.Text = string.Empty; } itemList.Add(item); } retList.Close(); } if (sortType == ProcessingEngine.Sort.Hot) { itemList = engine.SortItems(itemList, sortType); } return itemList; }
private void LoadItemDetails(string IID) { item = new Item(); // string queryString = "SELECT Title, Link, Text, Date, UID, NComments, Category FROM item WHERE IID=" + IID + ";"; string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE IID=" + IID + ";"; MySqlDataReader retList; retList = dbOps.ExecuteReader(queryString); if (retList != null && retList.HasRows) { while (retList.Read()) { item.IID = Convert.ToInt32(retList["IID"]); item.UID = Convert.ToString(retList["UID"]); item.Title = Convert.ToString(retList["Title"]); item.Link = Convert.ToString(retList["Link"]); item.Text = Convert.ToString(retList["Text"]); item.Date = Convert.ToString(retList["Date"]); item.NComments = Convert.ToInt32(retList["NComments"]); item.Category = Convert.ToString(retList["Category"]); item.Clicks = Convert.ToInt32(retList["Clicks"]); item.NSaved = Convert.ToInt32(retList["NSaved"]); item.NEMailed = Convert.ToInt32(retList["NEMailed"]); item.TagString = Convert.ToString(retList["Tags"]); item.TagList = general.ConvertCSVToList(item.TagString); item.AvgRating = Convert.ToDouble(retList["AvgRating"]); item.NRated = Convert.ToInt32(retList["NRated"]); item.Age = item.GetAge(item.Date); // item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age); item.Marks = item.GetMarks(item); if (!string.IsNullOrEmpty(item.Link)) { item.Text = string.Empty; } } retList.Close(); } Page.Title = item.Title + " - getputs.com"; // Vatsal Shah // 2009-01-12 // The code below is not used. ItemDisplayer.cs is used instead. /* ///////////////////////////////////////////////////////////////////////////////////////////////////// string commentString = "discuss"; List<int> savedItems = null; List<int> ratedItems = null; if (!string.IsNullOrEmpty(UID)) { // Get the list of items that have been saved by the User only if the User is logged in. savedItems = general.GetSavedItemIID(UID); ratedItems = general.GetRatedItemsIID(UID); } if (!string.IsNullOrEmpty(item.Link)) { //HyperLink linkItemHL = new HyperLink(); //linkItemHL.CssClass = "CSS_LinkItem"; //linkItemHL.Text = item.Title; //// linkItemHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + item.Link; //linkItemHL.NavigateUrl = item.Link; //ItemDiv.Controls.Add(linkItemHL); string linkItemHL = "<a class='CSS_LinkItem' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + item.Link + "'>" + item.Title + "</a>"; ItemDiv.Controls.Add(new LiteralControl(linkItemHL)); Uri uri = new Uri(item.Link); string website = uri.Host; HyperLink websiteLink = new HyperLink(); websiteLink.Text = " " + "[" + website.Replace("www.", "") + "]"; websiteLink.CssClass = "CSS_ItemDomain"; websiteLink.Target = "_blank"; websiteLink.NavigateUrl = "http://" + website; ItemDiv.Controls.Add(websiteLink); } else { //HyperLink textItemHL = new HyperLink(); //textItemHL.Text = item.Title; //textItemHL.CssClass = "CSS_TextItem"; //// textItemHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString(); //textItemHL.NavigateUrl = links.ItemDetailsPageLink + "?iid=" + item.IID.ToString(); //ItemDiv.Controls.Add(textItemHL); string textItemHL = "<a class='CSS_LinkItem' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString() + "'>" + item.Title + "</a>"; ItemDiv.Controls.Add(new LiteralControl(textItemHL)); } // Add an icon to open the link in a new window/tab. if (imageEngine.IsIconsOn) { string iconLocation = imageEngine.LoadStaticIconLocation("NewWindow"); if (!string.IsNullOrEmpty(iconLocation)) { ItemDiv.Controls.Add(new LiteralControl(" ")); iconLocation = iconLocation.Replace("~\\", ""); string newWindow = string.Empty; if (!string.IsNullOrEmpty(item.Link)) // Link Submission { // Redirect via R.aspx // newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='R.aspx?iid=" + item.IID.ToString() + "&url=" + item.Link + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> "; // Redirect Directly, Bypass R.aspx newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='" + item.Link + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> "; } else // Text Submission { // Redirect via R.aspx // newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='R.aspx?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString() + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> "; // Redirect Directly, Bypass R.aspx newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='" + links.ItemDetailsPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> "; } LiteralControl NewWindowLiteral = new LiteralControl(newWindow); ItemDiv.Controls.Add(NewWindowLiteral); } } ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak)); //HyperLink userHL = new HyperLink(); //userHL.Text = item.UID; //userHL.Font.Underline = false; //userHL.CssClass = "CSS_Submitter"; //userHL.NavigateUrl = links.UserDetailsPageLink + "?UID=" + item.UID; //ItemDiv.Controls.Add(userHL); //ItemDiv.Controls.Add(new LiteralControl(seperator)); string userHL = "<a class='CSS_Submitter' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.UserDetailsPageLink.Replace("~\\", "") + "?UID=" + item.UID + "' >" + item.UID + "</a>"; ItemDiv.Controls.Add(new LiteralControl(userHL + seperator)); string dateFormatString = gui.SmallFontStart + gui.GrayFontStart + general.GetFormattedDate(item.Date) + gui.GrayFontEnd + gui.SmallFontEnd; Label dateLabel = new Label(); dateLabel.Text = dateFormatString; dateLabel.CssClass = "CSS_SubmissionFreshness"; ItemDiv.Controls.Add(dateLabel); ItemDiv.Controls.Add(new LiteralControl(seperator)); if (!string.IsNullOrEmpty(item.Category)) { //if (imageEngine.IsIconsOn) //{ // string iconLocation = imageEngine.LoadIconLocation(item.Category); // if (!string.IsNullOrEmpty(iconLocation)) // { // System.Web.UI.WebControls.Image icon = new System.Web.UI.WebControls.Image(); // icon.ImageUrl = iconLocation; // icon.ImageAlign = ImageAlign.AbsMiddle; // icon.ToolTip = item.Category; // ItemDiv.Controls.Add(icon); // ItemDiv.Controls.Add(new LiteralControl(" ")); // } //} //HyperLink categoryHL = new HyperLink(); //categoryHL.Text = item.Category; //categoryHL.CssClass = "CSS_Category"; //categoryHL.NavigateUrl = links.CategoryPageLink + "?category=" + item.Category; //ItemDiv.Controls.Add(categoryHL); //ItemDiv.Controls.Add(new LiteralControl(seperator)); string iconLocation = imageEngine.LoadIconLocation(item.Category); if (!string.IsNullOrEmpty(iconLocation)) { string categoryHL = "<img border= '0' style='vertical-align:middle;' src='" + iconLocation.Replace("~\\", "") + "' alt=''/>" + " " + "<a class='CSS_Category' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.CategoryPageLink.Replace("~\\", "") + "?category=" + item.Category + "'>" + item.Category + "</a>"; ItemDiv.Controls.Add(new LiteralControl(categoryHL + seperator)); } } if (!string.IsNullOrEmpty(user)) // Show the Saved link only if the User is logged in. { // List<int> savedItems = general.GetSavedItemIID(user); LinkButton saveLB = new LinkButton(); saveLB.Click += new EventHandler(saveLB_Click); saveLB.Text = "save"; saveLB.CssClass = "CSS_Save"; saveLB.Attributes.Add("IID", item.IID.ToString()); if (savedItems != null && savedItems.Count > 0) { if (savedItems.Contains(item.IID)) { // Do not show the Save Link. } else { // Show the Save Link. ItemDiv.Controls.Add(saveLB); ItemDiv.Controls.Add(new LiteralControl(seperator)); } } else { // Show the Save Link. ItemDiv.Controls.Add(saveLB); ItemDiv.Controls.Add(new LiteralControl(seperator)); } } if (engine.IsEMailOn) { //string emailIconLocation = imageEngine.LoadStaticIconLocation("EMail"); //if (!string.IsNullOrEmpty(emailIconLocation)) //{ // System.Web.UI.WebControls.ImageButton emailIB = new ImageButton(); // emailIB.ImageUrl = emailIconLocation; // emailIB.ToolTip = "EMail/Share this Item"; // emailIB.Click += new ImageClickEventHandler(emailIB_Click); // emailIB.ImageAlign = ImageAlign.AbsMiddle; // // emailIB.Attributes.Add("IID", item.IID.ToString()); // emailIB.Attributes.Add("IID", IID); // ItemDiv.Controls.Add(emailIB); // ItemDiv.Controls.Add(new LiteralControl(seperator)); //} string emailIconLocation = imageEngine.LoadStaticIconLocation("EMail"); if (!string.IsNullOrEmpty(emailIconLocation)) { string eMailHL = "<img title='E-Mail/Share this Item' border= '0' style='vertical-align:middle;' src='" + emailIconLocation.Replace("~\\", "") + "' alt='E-Mail'/>" + " " + "<a class='CSS_EMailLink' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.SendItemMailPageLink.Replace("~\\", "") + "?IID=" + item.IID + "'>E-Mail</a>"; ItemDiv.Controls.Add(new LiteralControl(eMailHL + seperator)); } } //if (item.NComments > 0) //{ // commentString = item.NComments == 1 ? (item.NComments.ToString() + " comment") : (item.NComments.ToString() + " comments"); //} //HyperLink commentsHL = new HyperLink(); //commentsHL.CssClass = "CSS_Comments"; //commentsHL.Text = commentString; //// commentsHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString(); //commentsHL.NavigateUrl = links.ItemDetailsPageLink + "?iid=" + iid; //ItemDiv.Controls.Add(commentsHL); if (item.NComments > 0) { commentString = item.NComments == 1 ? (item.NComments.ToString() + " comment") : (item.NComments.ToString() + " comments"); } string commentsHL = "<a class='CSS_Comments' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString() + "'>" + commentString + "</a>"; ItemDiv.Controls.Add(new LiteralControl(commentsHL)); ///////////////////////////////////////////////////////////////////////////////////////////////////// */ List<Item> itemList = new List<Item>(1); itemList.Add(item); ItemDisplayer.ShowItemsOptions itemOptions = ItemDisplayer.ShowItemsOptions.ShowUIDLink | ItemDisplayer.ShowItemsOptions.ShowTime | ItemDisplayer.ShowItemsOptions.ShowCategoryLink | ItemDisplayer.ShowItemsOptions.ShowSaveLink | ItemDisplayer.ShowItemsOptions.ShowEMailLink | ItemDisplayer.ShowItemsOptions.ShowCommentsLink | ItemDisplayer.ShowItemsOptions.ShowImage | ItemDisplayer.ShowItemsOptions.ShowRatings | ItemDisplayer.ShowItemsOptions.ShowTags | ItemDisplayer.ShowItemsOptions.CountClicks; // The variable user = Logged In User, UID = User who submitted the item. string itemTable = itemDisplayer.LoadItemTable(itemList, itemOptions, itemLayoutOptions, 0, user, ProcessingEngine.Sort.Hot, links.ItemDetailsPageLink.Replace("~\\", "")); ItemDiv.Controls.Add(new LiteralControl(itemTable)); if (!string.IsNullOrEmpty(item.Text)) { string itemText = general.ProcessTextForDisplay(item.Text); Label itemTextLabel = new Label(); itemTextLabel.Text = itemText; itemTextLabel.CssClass = "CSS_ItemTextDetails"; ItemDiv.Controls.Add(itemTextLabel); ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak)); } ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak)); #region DirectContactButton // If the Direct Contact Tags List (from the Web.Config) contains the current Item.Category // Display the DirectContactButton // Else // Do not display the DirectContactButton UID = item.UID; if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(UID) && !string.IsNullOrEmpty(item.Category)) { if (categories.CategoriesListDirectContact != null && categories.CategoriesListDirectContact.Count > 0) { if(categories.CategoriesListDirectContact.Contains(item.Category)) { DirectContactButton.Visible = true; } } } #endregion DirectContactButton }
private List<Item> GetSimilarlyTaggedItems(string tag) { List<Item> itemList = new List<Item>(); // SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags FROM item WHERE Spam = 0 AND (Tags LIKE '%scrabulous,%' OR Tags LIKE '%,scrabulous') ORDER BY IID DESC LIMIT 25; string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE Spam = 0 AND (Tags LIKE '%" + tag + "," + "%' OR Tags LIKE '%" + "," + tag + "%' OR Tags LIKE '" + tag + "') ORDER BY IID DESC LIMIT " + engine.MaxItems.ToString() + ";"; MySqlDataReader retList; retList = dbOps.ExecuteReader(queryString); if (retList != null && retList.HasRows) { while (retList.Read()) { Item item = new Item(); item.IID = Convert.ToInt32(retList["IID"]); item.Title = Convert.ToString(retList["Title"]); item.Link = Convert.ToString(retList["Link"]); item.Text = Convert.ToString(retList["Text"]); item.Date = Convert.ToString(retList["Date"]); item.UID = Convert.ToString(retList["UID"]); item.NComments = Convert.ToInt32(retList["NComments"]); item.Category = Convert.ToString(retList["Category"]); item.Clicks = Convert.ToInt32(retList["Clicks"]); item.NSaved = Convert.ToInt32(retList["NSaved"]); item.NEMailed = Convert.ToInt32(retList["NEMailed"]); item.TagString = Convert.ToString(retList["Tags"]); item.TagList = general.ConvertCSVToList(item.TagString); item.AvgRating = Convert.ToDouble(retList["AvgRating"]); item.NRated = Convert.ToInt32(retList["NRated"]); item.Age = item.GetAge(item.Date); // item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age); item.Marks = item.GetMarks(item); if (!string.IsNullOrEmpty(item.Link)) { item.Text = string.Empty; } itemList.Add(item); } retList.Close(); } if (sort == ProcessingEngine.Sort.Hot) { itemList = engine.SortItems(itemList, sort); } return itemList; }
public List<Item> LoadSearchResults(string query) { List<Item> itemList = new List<Item>(); string queryString = "SELECT * FROM item WHERE Title LIKE '%" + query + "%' LIMIT " + _maxSearchResults + ";"; MySqlDataReader retList = dbOps.ExecuteReader(queryString); retList = dbOps.ExecuteReader(queryString); if (retList != null && retList.HasRows) { while (retList.Read()) { Item item = new Item(); item.IID = Convert.ToInt32(retList["IID"]); item.Title = Convert.ToString(retList["Title"]); item.Link = Convert.ToString(retList["Link"]); item.Text = Convert.ToString(retList["Text"]); item.Date = Convert.ToString(retList["Date"]); item.UID = Convert.ToString(retList["UID"]); item.NComments = Convert.ToInt32(retList["NComments"]); item.Category = Convert.ToString(retList["Category"]); item.Clicks = Convert.ToInt32(retList["Clicks"]); item.NSaved = Convert.ToInt32(retList["NSaved"]); item.NEMailed = Convert.ToInt32(retList["NEMailed"]); item.TagString = Convert.ToString(retList["Tags"]); item.TagList = general.ConvertCSVToList(item.TagString); item.AvgRating = Convert.ToDouble(retList["AvgRating"]); item.NRated = Convert.ToInt32(retList["NRated"]); item.Age = item.GetAge(item.Date); // item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age); item.Marks = item.GetMarks(item); if (!string.IsNullOrEmpty(item.Link)) { item.Text = string.Empty; } itemList.Add(item); } retList.Close(); } return itemList; // ItemDiv.InnerHtml = LoadItems(itemList); // LoadItemTable(itemList); }
public List<Item> LoadSearchResults(string query, SearchType sType, string sCategory, SearchTime sTime) { List<Item> itemList = new List<Item>(); List<string> queryTokens = tokenizer.GetTokens(query, true, true); List<int> alreadyAddedIIDs = new List<int>(); if (queryTokens != null) { for (int i = 0; i < queryTokens.Count; i++) { string currentQueryToken = queryTokens[i]; string queryString = QueryBuilder(currentQueryToken, sType, sCategory, sTime); Logger log = Logger.Instance; log.Log("Search QueryString: " + queryString); // queryString = "SELECT * FROM item WHERE Title LIKE '%" + query + "%' LIMIT " + _maxSearchResults + ";"; // string queryString = "SELECT * FROM item WHERE Title LIKE '%" + query + "%' LIMIT " + _maxSearchResults + ";"; MySqlDataReader retList = dbOps.ExecuteReader(queryString); retList = dbOps.ExecuteReader(queryString); if (retList != null && retList.HasRows) { while (retList.Read()) { Item item = new Item(); item.IID = Convert.ToInt32(retList["IID"]); item.Title = Convert.ToString(retList["Title"]); item.Link = Convert.ToString(retList["Link"]); item.Text = Convert.ToString(retList["Text"]); item.Date = Convert.ToString(retList["Date"]); item.UID = Convert.ToString(retList["UID"]); item.NComments = Convert.ToInt32(retList["NComments"]); item.Category = Convert.ToString(retList["Category"]); item.Clicks = Convert.ToInt32(retList["Clicks"]); item.NSaved = Convert.ToInt32(retList["NSaved"]); item.NEMailed = Convert.ToInt32(retList["NEMailed"]); item.TagString = Convert.ToString(retList["Tags"]); item.TagList = general.ConvertCSVToList(item.TagString); item.AvgRating = Convert.ToDouble(retList["AvgRating"]); item.NRated = Convert.ToInt32(retList["NRated"]); item.Age = item.GetAge(item.Date); // item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age); item.Marks = item.GetMarks(item); if (!string.IsNullOrEmpty(item.Link)) { item.Text = string.Empty; } if (!alreadyAddedIIDs.Contains(item.IID)) { alreadyAddedIIDs.Add(item.IID); itemList.Add(item); } } retList.Close(); } } return itemList; // ItemDiv.InnerHtml = LoadItems(itemList); // LoadItemTable(itemList); } else { return null; } }