/// <summary> /// 关键字 /// </summary> public void getai() { int HourNumber = DateTime.Now.Hour; PostServer.Getcookie = FPPcokk.ToString(); //空调扇 string KKurl = "https://sycm.taobao.com/ipoll/live/industry/showTopItems.json?cateId=50017589&cateLevel=2&device=0&limit=100&page=1&seller=-1&size=50&token=9592cec50&_=1532944703615"; //蒸气刷 string KKurl = "https://sycm.taobao.com/ipoll/live/industry/showTopItems.json?cateId=50008553&cateLevel=2&device=0&limit=100&page=1&seller=-1&size=50&token=9592cec50&_=1532944703615"; //女童装 string KKurl = "https://sycm.taobao.com/ipoll/live/industry/showTopItems.json?cateId=50010518&cateLevel=2&device=0&limit=100&page=1&seller=-1&size=50&token=9592cec50&_=1532944703615"; string KKurl = "https://sycm.taobao.com/mc/rivalItem/analysis/getLiveKeywords.json?dateRange=" + CDateTime + "%7C" + CDateTime + "&dateType=today&pageSize=20&page=1&device=2&sellerType=0&cateId=" + CcateId + "&itemId=" + CItemid + "&topType=flow&indexCode=uv&_=1535778429590&token="; PostServer.GetHTTPTaobao(KKurl); string gHtml = PostServer.GetHtml; // ShowInfo(FPPcokk.ToString()); // ShowInfo(gHtml); JObject json = (JObject)JsonConvert.DeserializeObject(gHtml); string zone = json["data"]["data"].ToString(); string Sqldel = "delete from hqKeyword where DateHour=" + HourNumber + " and ItemID='" + CItemid + "' and DItemdate='" + CDateTime + "'"; Ms.ExeSQLNonQuery(Sqldel); JArray results = JArray.Parse(zone); for (int i = 0; i < results.Count; i++) { string shopNameID = results[i]["keyword"]["value"].ToString(); int Keynumber = int.Parse(results[i]["uv"]["value"].ToString()); // ShowInfo(bb + "----" + aa); string Sql = "INSERT INTO [hqKeyword]([shopName],[DateHour],[HouNumber],[ItemID],[DItemdate])VALUES('" + shopNameID + "'," + HourNumber + "," + Keynumber + "-(SELECT isnull(SUM(houNumber),0) FROM dbo.hqKeyword where shopname='" + shopNameID + "' and DateHour<" + HourNumber + " and ItemID='" + CItemid + "' and DItemdate='" + CDateTime + "'),'" + CItemid + "','" + CDateTime + "')"; // ShowInfo(Sql); Ms.ExeSQLNonQuery(Sql); // ShowInfo("关建字:" + results[i]["keyword"]["value"].ToString() + ":" + results[i]["uv"]["value"].ToString()); } Ms.ClearParameters(); Ms.AddParameter("@ItemID", CItemid, SQLServer.SQLDataType.SQLString, CItemid.Length, System.Data.ParameterDirection.Input); Ms.AddParameter("@paydate", CDateTime, SQLServer.SQLDataType.SQLDateTime, 4, System.Data.ParameterDirection.Input); //StringBuilder Sqll = new StringBuilder(); //Sqll.Append("SELECT [shopName],[DateHour],[HouNumber] into #KeyTable FROM [dbo].[hqKeyword] where itemid='"+ CItemid + "' and DItemdate='"+ CDateTime + "'"); //Sqll.Append("SELECT * FROM #KeyTable"); //Sqll.Append(" AS P"); //Sqll.Append(" PIVOT"); //Sqll.Append("("); //Sqll.Append("SUM(HouNumber/*行转列后 列的值*/) FOR "); //Sqll.Append("p.DateHour/*需要行转列的列*/ IN ([0],[23],[22],[21],[20],[19],[18],[17],[16],[15],[14],[13],[12],[11],[10],[9],[8],[7],[6],[5],[4],[3],[2],[1]/*列的值*/)"); //Sqll.Append(") AS T"); //Sqll.Append("GO"); // string GSql = "select * from [hqKeyword_View]";Ms.runSPDataSet("Y_hqKeyword").Tables[0]; // Sqll this.ultraGrid2.DataSource = Ms.runSPDataSet("Y_hqKeyword").Tables[0]; ultraGrid2.DisplayLayout.Bands[0].Columns[HourNumber.ToString()].SortIndicator = Infragistics.Win.UltraWinGrid.SortIndicator.Descending; }
public int SearchNewsByKeywordCount(string Keyword) { Keyword = Keyword.Trim(); int LoopCounter = 0; while (Keyword.IndexOf(" ") >= 0 && LoopCounter < 100) { Keyword = Keyword.Replace(" ", " "); LoopCounter++; } string[] KeywordArray = Keyword.Split(' '); string WhereClause = ""; for (int i = 0; i < KeywordArray.Length; i++) { if (i == 0) { WhereClause = "(CONTAINS(Title, N'" + KeywordArray[i] + "') or CONTAINS(Contents, N'" + KeywordArray[i] + "'))"; } else { WhereClause = WhereClause + " and (CONTAINS(Title, N'" + KeywordArray[i] + "') or CONTAINS(Contents, N'" + KeywordArray[i] + "'))"; } } string cnStr = ConfigurationManager.ConnectionStrings["KhabardaanConnectionString"].ConnectionString; SQLServer dal = new SQLServer(cnStr); dal.AddParameter("@WhereClause", WhereClause, SQLServer.SQLDataType.SQLNVarchar, 4000, ParameterDirection.Input); DataSet ds = dal.runSPDataSet("dbo.spSearchNewsCount", null); dal.ClearParameters(); DataTable dt = ds.Tables[0]; return(Convert.ToInt32(dt.Rows[0]["RecordCount"])); //return dataContext.ExecuteQuery<>(string.Format("exec spSearchNewsCount N'{0}'", WhereClause)); //return dataContext.spSearchNewsCount(WhereClause); }
internal DataTable SearchNews(int PageSize, int PageNo, string Keyword, out int ResultCount) { string WhereClause = Tools.MakeWhereClause(Keyword, "Title,Abstract"); string cnStr = ConfigurationManager.ConnectionStrings["AceNewsConnectionString"].ConnectionString; SQLServer dal = new SQLServer(cnStr); // ************************************** Add SP Parameters ********************************************* dal.AddParameter("@WhereClause", WhereClause, SQLServer.SQLDataType.SQLNVarchar, 500, ParameterDirection.Input); // ************************************** Add SP Parameters ********************************************* DataSet ds = dal.runSPDataSet("dbo.spSearchNews", null); dal.ClearParameters(); DataTable dt = ds.Tables[0]; ResultCount = dt.Rows.Count; return(dt); //int SkipCount = (PageNo - 1) * PageSize; //IQueryable<vNews> Result = dataContext.vNews.Where(p => p.Title.Contains(Keyword) || p.NewsBody.Contains(Keyword)); //ResultCount = Result.Count(); //Result = Result.Skip(SkipCount).Take(PageSize); //return Result; }