using GrapeCity.ActiveReports;
using System.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using MVCOne.Controllers;
using MVCOne.Models;
using GrapeCity.ActiveReports.Document;

namespace MVCOne
{
    /// <summary>
    /// WebService1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : GrapeCity.ActiveReports.Web.ReportService
    {
        //SectionReport definition;
        PageDocument _pageDocument;
        PageReport definition;

        [WebMethod]
        protected override object OnCreateReportHandler(string reportPath)
        {          
            HomeController a = new HomeController();
            definition = (PageReport)base.OnCreateReportHandler(reportPath);
            _pageDocument = new PageDocument(definition);
            definition.Document.LocateDataSource += new LocateDataSourceEventHandler(DataSource1);
            return definition;
        }
        void DataSource1(object sender, LocateDataSourceEventArgs args)//只加载了LocateDataSource方法一次
        {

           
            string connStr = Server.MapPath("/Data/NWind_CHS.mdb");
            DataTable dt = new DataTable();
            HomeController a = new HomeController();

            args.Data = a.returndata(connStr);
        }      
    }
}
