private string getAdsStat(string distributor, string startDate, string endDate, string blog, string url) { combineBlogDistributor(blog, distributor); string strSQL = ""; try { string strClause = String.IsNullOrEmpty(startDate) ? "" : string.Format(" and convert(date, a.click_time) >= '{0}'", startDate); string strClause2 = String.IsNullOrEmpty(endDate) ? "" : string.Format(" and convert(date, a.click_time) <= '{0}'", endDate); string strClause3 = ""; if (!string.IsNullOrEmpty(url)) { byte[] data = Convert.FromBase64String(url); string decodedString = Encoding.UTF8.GetString(data); strClause3 = string.Format(" and url = '{0}'", decodedString); } strSQL = string.Format("select a.url, a.page, a.click_time, b.alias from tb_page_visit_info_xango as b, tb_page_ads_click_stat as a where a.distributor='{0}'{1}{2}{3} and a.distributor = b.distributor and a.token = b.token group by a.url, a.page, a.click_time, b.alias order by a.click_time desc", distributor, strClause, strClause2, strClause3); } catch (Exception e) { AdssLogger.WriteLog("GetSampleAnalyticsInfo(getAdsStat) --- Exception: " + e.Message); return "{}"; } try { using (SqlConnection sc = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString)) { if (sc != null) { DataSet ds = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL); if (ds != null && ds.Tables.Count > 0) { List<AdsStatItem> aList = new List<AdsStatItem>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow r = ds.Tables[0].Rows[i]; AdsStatItem ai = new AdsStatItem(); ai.url = Convert.ToString(r[0]); ai.page = Convert.ToString(r[1]); ai.time = ((DateTime)r[2]).ToString("yyyy-MM-dd HH:mm:ss"); ai.alias = Convert.ToString(r[3]); aList.Add(ai); } return new JavaScriptSerializer().Serialize(aList); } } } } catch (Exception e) { //Trace.WriteLine(e.Message); AdssLogger.WriteLog("GetSampleAnalyticsInfo(getAdsStat) --- Exception: " + e.Message + " --- sql: " + strSQL); } return "{}"; }
private string getAdsQuickStat(string distributor, string startDate, string endDate, string blog) { combineBlogDistributor(blog, distributor); string strSQL = ""; try { string strClause = String.IsNullOrEmpty(startDate) ? "" : string.Format(" and convert(date, click_time) >= '{0}'", startDate); string strClause2 = String.IsNullOrEmpty(endDate) ? "" : string.Format(" and convert(date, click_time) <= '{0}'", endDate); //strSQL = string.Format("select url, page, count(*) as c from tb_page_ads_click_stat where distributor='{0}'{1}{2} group by distributor, url, page order by c desc", distributor, strClause, strClause2); strSQL = string.Format("select url, count(*) as c from tb_page_ads_click_stat where distributor='{0}'{1}{2} group by distributor, url order by c desc", distributor, strClause, strClause2); } catch (Exception e) { AdssLogger.WriteLog("GetSampleAnalyticsInfo(getAdsQuickStat) --- Exception: " + e.Message); return "{}"; } try { using (SqlConnection sc = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlserver"].ConnectionString)) { if (sc != null) { DataSet ds = SqlHelper.ExecuteDataset(sc, CommandType.Text, strSQL); if (ds != null && ds.Tables.Count > 0) { List<AdsStatItem> aList = new List<AdsStatItem>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow r = ds.Tables[0].Rows[i]; AdsStatItem ai = new AdsStatItem(); ai.url = Convert.ToString(r[0]); //ai.page = Convert.ToString(r[1]); ai.count = Convert.ToInt32(r[1]); aList.Add(ai); } return new JavaScriptSerializer().Serialize(aList); } } } } catch (Exception e) { //Trace.WriteLine(e.Message); AdssLogger.WriteLog("GetSampleAnalyticsInfo(getAdsQuickStat) --- Exception: " + e.Message + " --- sql: " + strSQL); } return "{}"; }