using System;
using System.Collections.Generic;
namespace Stat.web.v
{
    /// <summary>
    /// 
    /// </summary>
    public partial class SProvince : System.Web.UI.Page
    {
        /// <summary>
        /// 
        /// </summary>
        protected Model.StatInfo statModel = new Stat.Model.StatInfo();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            statModel.WebID = Plugin.Common.Rq_Int("wid");
            //
            Stat.Security.ISecurity security = Stat.Security.DataFatory.CreateSecurity();
            security.CheckReportPower(statModel.WebID);
            //
            IList<Model.WebSites> website = Stat.Cache.CacheFatory.CreateWebSite().Get(statModel.WebID);
            if (website.Count > 0)
            {
                this.Page.Title = "国家/地区 " + website[0].WebName;
                if (!IsPostBack)
                {
                    statModel.StartTime = Plugin.Common.Rq_DateTime("st");
                    statModel.EndTime = Plugin.Common.Rq_DateTime("et");
                    //
                    DateTime dtNow = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    statModel.EndTime = statModel.EndTime > dtNow ? dtNow : statModel.EndTime;
                    statModel.StartTime = statModel.StartTime > statModel.EndTime ? statModel.EndTime : statModel.StartTime;
                    //
                    Show();
                }
            }
        }
        /// <summary>
        /// 分析数据
        /// </summary>
        protected void Show()
        {
            List<Model.StatItem> list = BLL.ViewProvince.Get(statModel);
            ShowReport(list);
            ShowHtml(list);
        }
        /// <summary>
        /// 
        /// </summary>
        protected void ShowHtml(List<Model.StatItem> list)
        {
            this.LtrProvinceList.Text = Stat.Html.ItemList.Get(list, statModel.WebID, "国家/省份", "pv", statModel.StartTime.ToShortDateString(), statModel.EndTime.ToShortDateString());
            Response.Flush();
        }
        /// <summary>
        /// 
        /// </summary>
        protected void ShowReport(List<Model.StatItem> list)
        {
            string strXML = Report.Map_China.GetXML(BLL.ViewProvince.GetChina(list));
            this.LtrRp_Province.Text = BLL.StatMaps.RenderMap("../MapsCharts/FCMap_China2.swf", "", strXML, "MapChina", "780", "400", false, false);
            Response.Flush();
        }
    }
}