public static List<Deals> GrabLatestDeals(bool newdealsonly) { // sp_getnewdeals MySqlConnection conn = new MySqlConnection(connStr); MySqlCommand cmd = conn.CreateCommand(); MySqlDataReader dr = null; cmd.CommandType = System.Data.CommandType.StoredProcedure; List<Deals> tmpList = new List<Deals>(); try { cmd.CommandText = "sp_getnewdeals"; cmd.Parameters.AddWithValue("@newdealsonly",newdealsonly); conn.Open(); cmd.CommandTimeout = 60; // increase timeout to 60, just in case of busy or locking dr = cmd.ExecuteReader(); while (dr.Read()) { Deals tmpModel = new Deals(); tmpModel.dealsID = (int)dr["dealsID"]; tmpModel.Title = (string)dr["Title"]; tmpModel.URL = (string)dr["URL"]; tmpModel.Ishot = (bool)dr["Ishot"]; tmpList.Add(tmpModel); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { conn.Close(); if (dr != null) dr.Dispose(); cmd.Dispose(); } return tmpList; }
// improve 1. sequence, 2. timestamp after link // the hot deal icon for now... // http://freebiesdealsandrewards.com/forum/images/icons/hot-deal.png // private string MakeUp(Deals tmpdeal,string keywords) { string andsplit = "~^~"; string exlcudesplit = "!^!"; string[] splitarray = { andsplit, exlcudesplit }; // grab the deal, and format it... string tmptitle = tmpdeal.Title; string[] keys = keywords.Split(','); foreach(string key in keys) // todo: && || keyword, need split again..... { if (key.Contains(andsplit) || key.Contains(exlcudesplit)) { string[] subkeys = key.Split(splitarray, StringSplitOptions.RemoveEmptyEntries); foreach (string subkey in subkeys) { if (!key.Contains(exlcudesplit + subkey)) { //tmptitle = tmptitle.Replace(subkey, "<span style='background-color:Yellow'><b><u>" + subkey + "</u></b></span>"); tmptitle = ReplaceEx(tmptitle, subkey, "<span style='background-color:Yellow'><b><u>" + subkey.ToUpper() + "</u></b></span>"); } } } else tmptitle = ReplaceEx(tmptitle, key, "<span style='background-color:Yellow'><b><u>" + key.ToUpper() + "</u></b></span>"); //tmptitle = tmptitle.Replace(key, "<span style='background-color:Yellow'><b><u>" + key + "</u></b></span>"); } string ishot = tmpdeal.Ishot ? "<img src='http://freebiesdealsandrewards.com/forum/images/icons/hot-deal.png' alt='Hot Deal' border='0' />" : ""; string content = "<div ><a href='" + tmpdeal.URL + "'>" + tmptitle + "</a>" + ishot + "</div><i> (" + tmpdeal.InDate.ToString() + ")</i><br/><br/>"; Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine(tmpdeal.Title.ToLower()); return content; }
public static Deals GetOneDeal(int dealid) { MySqlConnection conn = new MySqlConnection(connStr); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandType = System.Data.CommandType.Text; MySqlDataReader dr = null; Deals tmpModel = new Deals(); try { cmd.CommandText = "select * from rssdeals where dealsid =" + dealid; conn.Open(); cmd.CommandTimeout = 60; // increase timeout to 60, just in case of busy or locking dr = cmd.ExecuteReader(); while (dr.Read()) { tmpModel.PubDate = (string)dr["PubDate"]; tmpModel.dealsID = (int)dr["dealsID"]; tmpModel.URL = (string)dr["URL"]; tmpModel.Title = (string)dr["Title"]; tmpModel.InDate = (DateTime)dr["inTime"]; tmpModel.IsDrug = (bool)dr["IsDrug"]; tmpModel.IsFinance = (bool)dr["IsFinance"]; //tmpModel.IsFree = (bool)dr["IsFree"]; tmpModel.Ishot = (bool)dr["Ishot"]; tmpModel.IsTravel = (bool)dr["IsTravel"]; tmpModel.IsElectronic = (bool)dr["IsElectronic"]; tmpModel.IsAppeal = (bool)dr["IsAppeal"]; tmpModel.IsAppliances = (bool)dr["IsAppliances"]; tmpModel.IsBeauty = (bool)dr["IsBeauty"]; tmpModel.IsJewelry = (bool)dr["IsJewelry"]; tmpModel.IsOfficeSupplies = (bool)dr["IsOfficeSupplies"]; tmpModel.IsRestaurant = (bool)dr["IsRestaurant"]; tmpModel.IsOthers = (bool)dr["IsOthers"]; } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { conn.Close(); if (dr != null) dr.Dispose(); cmd.Dispose(); } return tmpModel; }