<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WeekReport.aspx.cs" Inherits="IWOMTrends.WeekReport" EnableViewState="false" %>
报告详情
using System;
using System.Data;
using System.Web.UI;
using System.Text;
using IWOMTrackerDBLayer.IWOMTrackerBLL;
using IWOMTrends.Common;
using IWOMTrackerDBLayer.Common;
using IWOMTrackerDBLayer.IWOMTrackerModel;
namespace IWOMTrends
{
public partial class WeekReport : System.Web.UI.Page
{
public LoginUserModel loginUser;
public string rContent;
public string rTitle;
public int brandID = 0;
//图表参数
public string WeekXValue = "";
public string WeekValueArr = "";
public string Positive = "";
public string Negative = "";
public string NegServiceX = "";
public string NegServiceVal = "";
public string NegServiceY = "";
public string PostServiceX = "";
public string PostServiceVal = "";
public string PostServiceY = "";
public string NegAreaX = "";
public string NegAreaVal = "";
public string NegTopicX = "";
public string NegTopicVal = "";
public string IndustryX = "";
public string IndustryVal = "";
public string DealDataX = "";
public string DealDataVal = "";
public string cookievalue = System.Configuration.ConfigurationManager.AppSettings["BrandCookie"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Refere"] != null && Request["Refere"] != "")
{ brandID = 20002; }
else
{
loginUser = LoginUserManager.GetLoginUser(true);
//判断权限
if (!CommonFunction.CheckUserQX(loginUser, Request.Cookies[cookievalue]))
Response.Redirect("~/Login.aspx", true);
brandID = int.Parse(Request.Cookies[cookievalue].Value);
}
this.HidBrand.Value = brandID.ToString();
if (!IsPostBack)
{
GetWeekReport();
}
}
private void GetWeekReport()
{
if (Request.QueryString["zhou"] != null && Request.QueryString["zhou"].ToString() == "week")
{
IWT_Brand brandObj = BrandBLL.GetModel(brandID);
rTitle = brandObj.Brand_Name + "网络口碑监测周报";
this.divDown.Visible = true;
tongji.Visible = true;
string number = Request["value"].ToString().Substring(0, 1);
string StrDate = Request["value"].ToString().Substring(5, Request["value"].ToString().Substring(5).LastIndexOf("-"));
DateTime dt1 = DateTime.Now;
DateTime dt2 = DateTime.Now;
int index = 0;
DateTime[] Arr_dt = new DateTime[5];
DateTime startdt = Convert.ToDateTime(StrDate + "-1");
DateTime enddt = startdt.AddMonths(1).AddDays(-1);
for (DateTime i = startdt; i <= enddt; i = i.AddDays(1))
{
if (Convert.ToInt32(i.DayOfWeek) == 1)
{
Arr_dt[index] = i;
index++;
}
}
if (number == "1")
{
dt2 = Arr_dt[0];
dt1 = dt2.AddDays(6);
}
else if (number == "2")
{
dt2 = Arr_dt[1];
dt1 = dt2.AddDays(6);
}
else if (number == "3")
{
dt2 = Arr_dt[2];
dt1 = dt2.AddDays(6);
}
else if (number == "4")
{
dt2 = Arr_dt[3];
dt1 = dt2.AddDays(6);
}
else if (number == "5")
{
dt2 = Arr_dt[4];
dt1 = dt2.AddDays(6);
}
if(dt1 > DateTime.Now)
{
dt1 = DateTime.Now;
}
rContent = dt2.ToShortDateString() + "至" + dt1.ToShortDateString();
if (brandID == 30001)
{
FirstAllTable(dt2, dt1);
SecondNegServiceData(dt2, dt1);
GetNegAreaData(dt2, dt1);
FourNegTopicData(dt2, dt1);
FourNegTopicData1(dt2, dt1);
FiveIndustryTopic(dt2, dt1);
SixDealData(dt2, dt1);
SixDealData1(dt2, dt1);
SevenMediaData(dt2, dt1);
}
}
}
//第一个表格
private void FirstAllTable(DateTime dt2, DateTime dt1)
{
DataTable dtt = DailyWeeklyBLL.GetAllDataByWeely(brandID, dt2, dt1, ref WeekXValue, ref WeekValueArr, ref Positive, ref Negative, false);
tongji.InnerHtml = CommonFunction.ExportHTML(dtt, "90%", "tblCSS");
}
//第二个表格
private void SecondNegServiceData(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetServiceByWeely(brandID, dt2, dt1, true, ref NegServiceX, ref NegServiceY, ref NegServiceVal, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "80%", "tblCSS"));
this.fumiantongji.InnerHtml = strB.ToString();
dtable = DailyWeeklyBLL.GetServiceByWeely(brandID, dt2, dt1, false, ref PostServiceX, ref PostServiceY, ref PostServiceVal, false);
strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "80%", "tblCSS"));
this.prodAttitdeHTML.InnerHtml = strB.ToString();
}
//第三个表格
private void GetNegAreaData(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetNegAreaData(brandID, dt2, dt1, ref NegAreaX, ref NegAreaVal, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "80%", "tblCSS"));
this.tongji2.InnerHtml = strB.ToString();
}
//第四个表格
private void FourNegTopicData(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetNegAreaData1(brandID, dt2, dt1, ref NegTopicX, ref NegTopicVal, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "99%", "tblCSS"));
this.fumiantongji2.InnerHtml = strB.ToString();
}
private void FourNegTopicData1(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetNegAreaData11(brandID, dt2, dt1, ref NegTopicX, ref NegTopicVal, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "99%", "tblCSS"));
this.fumiantongji3.InnerHtml = strB.ToString();
}
//第五个表格
private void FiveIndustryTopic(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetIndustryData(30006, dt2, dt1, ref IndustryX, ref IndustryVal, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "80%", "tblCSS"));
this.IndustryHtml.InnerHtml = strB.ToString();
}
//第六个表格
private void SixDealData(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetDealData(brandID, dt2, dt1, ref DealDataX, ref DealDataVal, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "99%", "tblCSS"));
this.DealDataHTML.InnerHtml = strB.ToString();
}
private void SixDealData1(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetDealData1(brandID, dt2, dt1, ref DealDataX, ref DealDataVal, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "99%", "tblCSS"));
this.DealDataHTML1.InnerHtml = strB.ToString();
}
//第七个表格
private void SevenMediaData(DateTime dt2, DateTime dt1)
{
DataTable dtable = DailyWeeklyBLL.GetMediaData(brandID, dt2, dt1, false);
StringBuilder strB = new StringBuilder();
strB.Append(CommonFunction.ExportHTML(dtable, "60%", "tblCSS"));
this.MediaHtml.InnerHtml = strB.ToString();
}
//导出
protected void lbn_down_Click(object sender, ImageClickEventArgs e)
{
if (Request.QueryString["zhou"] != null && Request.QueryString["zhou"].ToString() == "week")
{
IWT_Brand brandObj = BrandBLL.GetModel(brandID);
#region 计算日期
this.divDown.Visible = true;
tongji.Visible = true;
string number = Request["value"].ToString().Substring(0, 1);
string StrDate = Request["value"].ToString().Substring(5, Request["value"].ToString().Substring(5).LastIndexOf("-"));
DateTime dt1 = DateTime.Now;
DateTime dt2 = DateTime.Now;
int index = 0;
DateTime[] Arr_dt = new DateTime[5];
DateTime startdt = Convert.ToDateTime(StrDate + "-1");
DateTime enddt = startdt.AddMonths(1).AddDays(-1);
for (DateTime i = startdt; i <= enddt; i = i.AddDays(1))
{
if (Convert.ToInt32(i.DayOfWeek) == 1)
{
Arr_dt[index] = i;
index++;
}
}
if (number == "1")
{
dt2 = Arr_dt[0];
dt1 = dt2.AddDays(6);
}
else if (number == "2")
{
dt2 = Arr_dt[1];
dt1 = dt2.AddDays(6);
}
else if (number == "3")
{
dt2 = Arr_dt[2];
dt1 = dt2.AddDays(6);
}
else if (number == "4")
{
dt2 = Arr_dt[3];
dt1 = dt2.AddDays(6);
}
else if (number == "5")
{
dt2 = Arr_dt[4];
dt1 = dt2.AddDays(6);
}
#endregion
DataTable dt = new DataTable();
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
dt.Columns.Add(" ");
rTitle = brandObj.Brand_Name + "网络口碑监测周报";
rContent = dt2.ToShortDateString() + "至" + dt1.ToShortDateString();
DataRow row = dt.NewRow();
row[0] = rContent + " " + rTitle;
for (int i = 1; i < 11; i++)
{
row[i] = "";
}
dt.Rows.Add(row);
row = dt.NewRow();
for (int i = 0; i < 11; i++)
{
row[i] = "";
}
dt.Rows.Add(row);
if (brandID == 30001)
{
string[] titleArr = new string[10] { "一周信息量", "负面媒体类型构成", "正面媒体类型构成", "WSE负面信息地理分布", "WSE负面话题构成", "", "行业信息内容构成", "维护信息的内容情况", "", "维护信息的媒体" };
DataTable[] dtArr = new DataTable[10];
dtArr[0] = DailyWeeklyBLL.GetAllDataByWeely(brandID, dt2, dt1, ref WeekXValue, ref WeekValueArr, ref Positive, ref Negative, false);
dtArr[1] = DailyWeeklyBLL.GetServiceByWeely(brandID, dt2, dt1, true, ref NegServiceX, ref NegServiceY, ref NegServiceVal, false);
dtArr[2] = DailyWeeklyBLL.GetServiceByWeely(brandID, dt2, dt1, false, ref PostServiceX, ref PostServiceY, ref PostServiceVal, false);
dtArr[3] = DailyWeeklyBLL.GetNegAreaData(brandID, dt2, dt1, ref NegAreaX, ref NegAreaVal, false);
dtArr[4] = DailyWeeklyBLL.GetNegAreaData1(brandID, dt2, dt1, ref NegTopicX, ref NegTopicVal, false);
dtArr[5] = DailyWeeklyBLL.GetNegAreaData11(brandID, dt2, dt1, ref NegTopicX, ref NegTopicVal, false);
dtArr[6] = DailyWeeklyBLL.GetIndustryData(30006, dt2, dt1, ref IndustryX, ref IndustryVal, false);
dtArr[7] = DailyWeeklyBLL.GetDealData(brandID, dt2, dt1, ref DealDataX, ref DealDataVal, false);
dtArr[8] = DailyWeeklyBLL.GetDealData1(brandID, dt2, dt1, ref DealDataX, ref DealDataVal, false);
dtArr[9] = DailyWeeklyBLL.GetMediaData(brandID, dt2, dt1, false);
DataRow drow;
for (int k = 0; k < dtArr.Length; k++)
{
if (dtArr[k] != null && dtArr[k].Rows.Count > 0)
{
row = dt.NewRow();
row[0] = titleArr[k];
for (int i = 1; i < 11; i++)
{
row[i] = "";
}
dt.Rows.Add(row);
foreach (DataRow dr in dtArr[k].Rows)
{
drow = dt.NewRow();
for (int i = 0; i < 11; i++)
{
if (i < dr.ItemArray.Length)
drow[i] = dr[i].ToString();
}
dt.Rows.Add(drow);
}
row = dt.NewRow();
for (int i = 0; i < 11; i++)
{
row[i] = "";
}
dt.Rows.Add(row);
}
}
string FileName = brandObj.Brand_Name + "_" + System.DateTime.Parse(Convert.ToString(System.DateTime.Now)).ToString("yyyy-MM-dd");
DataSet dsett = new DataSet();
dsett.Tables.Add(dt);
IWOMTrends.Common.CommonFunction.ExportCSV(dt, Page.Response, FileName, true);
}
}
}
}
}