Ejemplo n.º 1
0
        public ActionResult TestReports()
        {
            IContractDocumentHandler  hand = ServiceContainer.GetService <IContractDocumentHandler>() as IContractDocumentHandler;
            IList <RPTChangeNoticeDo> list = hand.GetRptChangeNoticeData(0);
            //IList<Presentation.Contract.Models.RPTChangeNoticeDo> listRpt = new List<Presentation.Contract.Models.RPTChangeNoticeDo>();
            //foreach(RPTChangeNoticeDo r in list){
            //    var t = new Presentation.Contract.Models.RPTChangeNoticeDo();
            //    t=CommonUtil.CloneObject<RPTChangeNoticeDo, Presentation.Contract.Models.RPTChangeNoticeDo>(r);
            //    listRpt.Add(t);
            //}



            ReportDocument rptH = new ReportDocument();
            //var path = ReportUtil.GetReportPath("Reports/CTR020_ChangeNotice.rpt",Server.MapPath("/"));
            //string path = ReportUtil.GetReportTemplatePath("CTR020_ChangeNotice.rpt");
            string path = PathUtil.GetPathValue(PathUtil.PathName.ReportTempatePath, "CTR020_ChangeNotice.rpt");

            rptH.Load(path);

            rptH.SetDataSource(list);
            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            rptH.Close();


            return(File(stream, "application/pdf"));
        }
Ejemplo n.º 2
0
        public ActionResult CTR020_ChangeNotice(int iDocID)
        {
            try
            {
                IContractDocumentHandler contractDocHandler = ServiceContainer.GetService <IContractDocumentHandler>() as IContractDocumentHandler;
                List <RPTChangeNoticeDo> rptList            = contractDocHandler.GetRptChangeNoticeData(iDocID);

                IDocumentHandler documentHandler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;

                //doDocumentDataGenerate doDoc = new doDocumentDataGenerate();
                //if (rptList.Count > 0)
                //{
                //    doDoc.DocumentNo = rptList[0].DocNo;
                //    doDoc.DocumentCode = rptList[0].DocumentCode;
                //    doDoc.DocumentData = rptList;
                //}

                //Stream stream = documentHandler.GenerateDocument(doDoc);

                string path = ReportUtil.GetReportPath("Reports/CTR020_ChangeNotice.rpt", Server.MapPath("/"));
                //string path = ReportUtil.GetReportTemplatePath("CTR020_ChangeNotice.rpt");

                ReportDocument rptH = new ReportDocument();
                rptH.Load(path);
                rptH.SetDataSource(rptList);
                Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                rptH.Close();

                return(File(stream, "application/pdf"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }