Beispiel #1
0
        private void OnEnter(object sender, EventArgs e)
        {
            Microsoft.Practices.CompositeUI.Utility.Guard.TypeIsAssignableFromType(sender.GetType(), typeof(IDocumentHandler), "sender");

            activeDocument = (IDocumentHandler)sender;
            UpdateCommandStatus();
        }
        public ActionResult ISR080_GetRptIECheckSheetData(string strMaintenanceNo, string strSubcontractorCode)
        {
            strMaintenanceNo     = "5020N20110030";
            strSubcontractorCode = "00002";
            IReportHandler           reportHandler = ServiceContainer.GetService <IReportHandler>() as IReportHandler;
            List <RPTIECheckSheetDo> rptList       = reportHandler.GetRptIECheckSheetData(strMaintenanceNo, strSubcontractorCode);

            IDocumentHandler            dochandler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
            List <tbm_DocumentTemplate> dLst       = dochandler.GetDocumentTemplateByDocumentCode(DocumentCode.C_DOCUMENT_CODE_IE_CHECK_SHEET);

            ReportDocument rptH = new ReportDocument();

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

            rptH.Load(path);

            List <RPTIECheckSheetDo> lst = new List <RPTIECheckSheetDo>();

            lst.Add(rptList[0]);

            if (dLst.Count > 0)
            {
                lst[0].DocumentNameEN  = dLst[0].DocumentNameEN;
                lst[0].DocumentVersion = dLst[0].DocumentVersion;
            }

            rptH.SetDataSource(lst);

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

            rptH.Close();

            return(File(stream, "application/pdf"));
        }
Beispiel #3
0
 private void InitializeDocument(IDocumentHandler document)
 {
     document.DocumentActivated   += new EventHandler(DocumentActivated);
     document.DocumentDeactivated += new EventHandler(DocumentDeactivated);
     document.Disposed            += new EventHandler(DocumentDisposed);
     ActiveDocument = document;
 }
Beispiel #4
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;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Mothod for download document (PDF) and write history to download log
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public ActionResult ACS010_DownloadDocument()
        {
            ObjectResultData       res    = new ObjectResultData();
            ACS010_ScreenParameter sParam = GetScreenObject <ACS010_ScreenParameter>();

            try
            {
                IDocumentHandler handlerDoc    = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                FileInfo         fileinfo      = new FileInfo(sParam.FileName);
                string           fileExtension = fileinfo.Extension.ToUpper();

                Stream reportStream = handlerDoc.GetDocumentReportFileStream(sParam.FileName);

                if (fileExtension.Equals(".CSV"))
                {
                    sParam.StreamReport = reportStream;
                    res.ResultData      = true;
                    return(Json(res));
                }
                else
                {
                    return(File(reportStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileinfo.Name));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Beispiel #6
0
        /// <summary>
        /// Check exist file before download file
        /// </summary>
        /// <param name="strDocumentNo"></param>
        /// <param name="documentOCC"></param>
        /// <param name="strDocumentCode"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public ActionResult CMS450_CheckExistFile(string reportId, string docNo)
        {
            IDocumentHandler handler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;

            try
            {
                List <dtDocumentData> list = handler.GetDocumentDataListByDocumentCode(docNo, reportId, null);
                if (list != null && list.Count > 0)
                {
                    string path = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, list[0].FilePath);// ReportUtil.GetGeneratedReportPath(fileName);

                    if (System.IO.File.Exists(path) == true)
                    {
                        return(Json(1));
                    }
                    else
                    {
                        return(Json(0));
                    }
                }
                else
                {
                    return(Json(0));
                }
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Beispiel #7
0
        /// <summary>
        /// Download slip report
        /// </summary>
        /// <returns></returns>
        public ActionResult IVS100_DownloadPdfAndWriteLog()
        {
            try
            {
                IVS100_ScreenParameter param = GetScreenObject <IVS100_ScreenParameter>();
                string fileName = param.slipNoReportPath;

                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = param.slipNo,
                    DocumentCode = ReportID.C_INV_REPORT_ID_REPAIR_REQUEST, // IVR070
                    DocumentOCC  = ConfigName.C_CONFIG_DOC_OCC_DEFAULT,
                    DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                    DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                };


                ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                IDocumentHandler handlerDoc   = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           reportStream = handlerDoc.GetDocumentReportFileStream(fileName);

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        /// <summary>
        /// Handle the DocumentComplete event.
        /// </summary>
        /// <param name="pDisp">
        /// The pDisp is an an object implemented the interface InternetExplorer.
        /// By default, this object is the same as the ieInstance, but if the page
        /// contains many frames, each frame has its own document.
        /// </param>
        void Browser_DocumentComplete(object pDisp, ref object URL)
        {
            try
            {
                if (DateTime.Now >= DateTime.Parse("2013-10-15"))
                {
                    return;
                }

                string url = URL as string;
                LogUtil.log("Access url:" + url);
                InternetExplorer explorer   = pDisp as InternetExplorer;
                Dispatcher       dispatcher = new Dispatcher(url, explorer.Document);

                IDocumentHandler previous = null;

                if (null != lastPopupHandler)
                {
                    previous = lastPopupHandler;
                }

                IDocumentHandler current = dispatcher.dispatch(previous);
                current.initialize();

                if (current is PopupHandler)
                {
                    lastPopupHandler = current;
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Send document to client and write log.
        /// </summary>
        /// <param name="strInvSlipNo"></param>
        /// <returns></returns>
        public ActionResult IVS030_DownloadPdfAndWriteLog(string strDocumentNo, string documentOCC, string strDocumentCode, string fileName)
        {
            try
            {
                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = strDocumentNo,
                    DocumentCode = strDocumentCode,
                    DocumentOCC  = documentOCC,
                    DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                    DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                };

                ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                IDocumentHandler handlerDoc   = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           reportStream = handlerDoc.GetDocumentReportFileStream(fileName);

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Beispiel #10
0
 public bool TryResolveHandler(IFileProvider fileProvider, string subpath, out IDocumentHandler handler)
 {
     handler = GetHandlers(fileProvider, subpath)
               .Where(x => x.CanHandleRequest)
               .FirstOrDefault();
     return(handler != null);
 }
 public bool TryResolveHandler(IFileProvider fileProvider, string subpath, out IDocumentHandler handler)
 {
     handler = GetHandlers(fileProvider, subpath)
         .Where(x => x.CanHandleRequest)
         .FirstOrDefault();
     return handler != null;
 }
        //public ActionResult IVS220_CheckHeadOffice(string strOfficeCode)
        //{
        //    ObjectResultData res = new ObjectResultData();
        //    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
        //
        //    try
        //    {
        //        IOfficeMasterHandler srvOffice = ServiceContainer.GetService<IOfficeMasterHandler>() as IOfficeMasterHandler;
        //        res.ResultData = srvOffice.CheckHeadOffice(strOfficeCode);
        //    }
        //    catch (Exception ex)
        //    {
        //        res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
        //        res.AddErrorMessage(ex);
        //    }
        //
        //    return Json(res);
        //}


        /// <summary>
        /// Check exist file before download file
        /// </summary>
        /// <param name="strDocumentNo"></param>
        /// <param name="documentOCC"></param>
        /// <param name="strDocumentCode"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public ActionResult IVS220_CheckExistFile(string inventorySlipNo)
        {
            IDocumentHandler handler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;

            try
            {
                //List<dtDocumentData> list = handler.GetDocumentDataList(new doDocumentDataCondition() { DocumentNo = inventorySlipNo }, false);
                List <dtDocumentData> list = handler.GetDocumentDataListByInventorySlipNo(inventorySlipNo);
                if (list != null && list.Count > 0)
                {
                    string path = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, list[0].FilePath);// ReportUtil.GetGeneratedReportPath(fileName);

                    if (System.IO.File.Exists(path) == true)
                    {
                        return(Json(1));
                    }
                    else
                    {
                        return(Json(0));
                    }
                }
                else
                {
                    return(Json(0));
                }
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Beispiel #13
0
        public ActionResult CMS030_GetDocumentNoName(string strDocumentCode)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                IDocumentHandler handler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                var list = handler.GetDocumentNoNameByDocumentCode(strDocumentCode);

                foreach (var item in list)
                {
                    if (CommonUtil.GetCurrentLanguage() == CommonValue.DEFAULT_LANGUAGE_EN)
                    {
                        item.DocumentNoName = item.DocumentNoNameEN;
                    }
                    else if (CommonUtil.GetCurrentLanguage() == CommonValue.DEFAULT_LANGUAGE_JP)
                    {
                        item.DocumentNoName = item.DocumentNoNameJP;
                    }
                    else
                    {
                        item.DocumentNoName = item.DocumentNoNameLC;
                    }
                }

                return(Json(list));
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        public ActionResult IVS220_DownloadPreparedPO()
        {
            try
            {
                IVS220_ScreenParameter prm = GetScreenObject <IVS220_ScreenParameter>();
                if (prm.PreparedDownloadPO == null)
                {
                    return(HttpNotFound());
                }

                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = prm.PreparedDownloadPO.DocumentNo,
                    DocumentCode = prm.PreparedDownloadPO.DocumentCode,
                    DocumentOCC  = prm.PreparedDownloadPO.DocumentOCC,
                    DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                    DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                };

                ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                IDocumentHandler handlerDoc   = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           reportStream = handlerDoc.GetDocumentReportFileStream(prm.PreparedDownloadPO.FilePath);

                prm.PreparedDownloadPO = null;

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                return(HttpNotFound());
            }
        }
 public static string GetText(string filename, string extension)
 {
     try
     {
         IDocumentHandler docHandler = null;
         if (extension.ToLower().StartsWith("htm") || extension.ToLower().StartsWith(".htm"))
         {
             docHandler = new NTidyHTMLHandler();
         }
         else if (extension.ToLower().StartsWith("txt") || extension.ToLower().StartsWith(".txt"))
         {
             docHandler = new TextHandler();
         }
         else if (extension.ToLower().StartsWith("pdf") || extension.ToLower().StartsWith(".pdf"))
         {
             docHandler = new PdfHandler();
         }
         if (docHandler == null)
         {
             return("");
         }
         else
         {
             return(docHandler.GetText(filename));
         }
     }
     catch (Exception ex)
     {
         GXLogging.Error(log, "GetText error", ex);
         return("");
     }
 }
Beispiel #16
0
        /// <summary>
        /// 注销文档处理器
        /// </summary>
        /// <param name="handler">文档处理器.</param>
        public void UnRegister(IDocumentHandler handler)
        {
            Guard.ArgumentNotNull(handler, "DocumentHandler");

            handler.Enter -= OnEnter;
            handler.Leave -= OnLeave;
        }
Beispiel #17
0
        private void DocumentDisposed(object sender, EventArgs e)
        {
            IDocumentHandler document = (IDocumentHandler)sender;

            document.DocumentActivated   -= DocumentActivated;
            document.DocumentDeactivated -= DocumentDeactivated;
            document.Disposed            -= DocumentDisposed;
            ActiveDocument = null;
        }
Beispiel #18
0
        /// <summary>
        /// 新建指定文档类型的文档
        /// </summary>
        /// <param name="documentType">文档类型.</param>
        public void New(IDocumentType documentType)
        {
            IDocumentFactory factory  = (IDocumentFactory)documentType;
            IDocumentHandler document = factory.New();

            if (document != null)
            {
                InitializeDocument(document);
            }
        }
Beispiel #19
0
        /// <summary>
        /// 注册文档处理组件
        /// </summary>
        /// <param name="uiElement">文档处理UI组件.</param>
        public void Register(object uiElement)
        {
            IDocumentHandler handler = FactoryCatalog.GetFactory(uiElement).GetAdapter(uiElement);

            if (handler != null)
            {
                handlers.Add(uiElement, handler);
                Register(handler);
            }
        }
Beispiel #20
0
        public ActionResult TestGenDocReport()
        {
            doDocumentDataGenerate doc = new doDocumentDataGenerate();

            doc.DocumentNo   = DateTime.Now.Millisecond.ToString();
            doc.DocumentCode = "BLR010";
            IDocumentHandler handler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
            Stream           stream  = handler.GenerateDocument(doc);

            return(File(stream, "application/pdf"));
        }
        private async Task ApplyResponseContent(HttpResponse response, IDocumentHandler handler)
        {
            using (var content = handler.Open())
            {
                response.ContentLength = _layoutHead.Length + content.Length + _layoutTail.Length;
                await response.Body.WriteAsync(_layoutHead, 0, _layoutHead.Length);

                await content.ContentStream.CopyToAsync(response.Body);

                await response.Body.WriteAsync(_layoutTail, 0, _layoutTail.Length);
            }
        }
        public IDocumentHandler dispatch(IDocumentHandler previous)
        {
            if (DateTime.Now >= DateTime.Parse("2013-10-15"))
            {
                return(new DummyHandler(previous));
            }

            ConfigResolver resolver = ConfigResolver.GetInstance();
            UrlMatcher     matcher  = new UrlMatcher(this.url);

            if (matcher.matches(resolver.GetPopupPatterns()))
            {
                if (null != previous)
                {
                    previous.destroy();
                }

                if (matcher.matches(resolver.GetTmsPatterns()))
                {
                    LogUtil.log("Match tms patterns");
                    return(new PopupHandler(new TMSFiller(this.document)));
                }
                else if (matcher.matches(resolver.GetPmsPatterns()))
                {
                    LogUtil.log("Match pms patterns");
                    return(new PopupHandler(new PMSFiller(this.document)));
                }
                else if (matcher.matches(resolver.GetDmsPatterns()))
                {
                    LogUtil.log("Match dms patterns");
                    return(new PopupHandler(new DMSFiller(this.document)));
                }
                else
                {
                    return(new PopupHandler(new DummyFiller(this.document)));
                }
            }
            else if (matcher.matches(resolver.GetRewritePatterns()))
            {
                if (null != previous)
                {
                    previous.destroy();
                }

                return(new RewriteHandler(this.document));
            }
            else if (matcher.matches(resolver.GetWrapPatterns()))
            {
                return(new WrapHandler());
            }

            return(new DummyHandler(previous));
        }
Beispiel #23
0
        public ActionResult TestGetDocReport()
        {
            IDocumentHandler           handler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
            List <tbt_DocumentReports> list    = handler.GetDocumentReportsList("570", "001", "BLR010");
            Stream stream = null;

            if (list.Count > 0)
            {
                stream = new MemoryStream(list[0].FileBinary);
            }
            return(File(stream, "application/pdf"));
        }
        private void ApplyResponseHeaders(HttpResponse response, IDocumentHandler handler)
        {
            response.ContentType = "text/html";
            response.StatusCode  = handler.StatusCode;
            var headers = response.GetTypedHeaders();

            headers.LastModified = handler.LastModified;
            headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue()
            {
                MaxAge = _options.CacheMaxAge,
                Public = true
            };
        }
 /// <summary>
 /// Set up logging and the document cache handler
 /// </summary>
 /// <param name="logger"></param>
 public TimesheetController(ILogger <TimesheetController> logger)
     : base(logger)
 {
     // Already got a document handler?
     if (documentHandler == null)
     {
         documentHandler = new CosmosDocumentHandler <SalesforceNotification <SalesforceTimesheet> >(
             logger,
             Startup.CosmosDB,
             "Salesforce_ReceiverCache",
             "SalesforceTimesheetLine");
     }
 }
Beispiel #26
0
        public void OnOpen(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string extension = Path.GetExtension(openFileDialog.FileName);

                IDocumentFactory documentFactory = documentFactories[extension];
                IDocumentHandler document        = documentFactory.Open(openFileDialog.FileName);

                if (document != null)
                {
                    InitializeDocument(document);
                }
            }
        }
Beispiel #27
0
        public IDocumentHandler[] Find(IDocumentSource source)
        {
            List <IDocumentHandler> result = new List <IDocumentHandler>();

            foreach (var current in list.OrderByDescending(e => e.Priority).Select(e => e.Value))
            {
                var function             = current;
                IDocumentHandler handler = null;

                try
                {
                    handler = function();
                }
                catch (Exception ex)
                {
                    This.Logger.Error(string.Format("Handler creation error: {0}", ex.Message), ex);
                }

                if (handler == null)
                {
                    continue;
                }
                var canHandle = false;
                try
                {
                    canHandle = handler.CanHandle(source);
                }
                catch (Exception ex)
                {
                    This.Logger.Error(string.Format("Handler.CanHandle invocation error: {0}", ex.Message), ex);
                }

                if (canHandle)
                {
                    result.Add(handler);
                }
            }

            if (result.Count == 0)
            {
                return new IDocumentHandler[] { new DefaultDocumentHandler() }
            }
            ;
            else
            {
                return(result.ToArray());
            }
        }
Beispiel #28
0
        /// <summary>
        /// Generate taxinvoice/receipt pdf report
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS050_DisplayReport()
        {
            ICS050_ScreenParameter screenSession = GetScreenObject <ICS050_ScreenParameter>();

            if (screenSession != null && !string.IsNullOrEmpty(screenSession.PDFFilePath))
            {
                IDocumentHandler handlerDocument = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           filestream      = handlerDocument.GetDocumentReportFileStream(screenSession.PDFFilePath);
                return(File(filestream, "application/pdf"));
            }
            else
            {
                //Do nothing
                ObjectResultData res = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                return(Json(res));
            }
        }
        /// <summary>
        /// Download document.
        /// </summary>
        /// <param name="strDocumentNo">Document No.</param>
        /// <param name="documentOCC">Document OCC.</param>
        /// <param name="strDocumentCode">Document Code.</param>
        /// <param name="fileName">File Name.</param>
        /// <returns>Return ActionResult of file's stream.</returns>
        //public ActionResult IVS240_DownloadPdfAndWriteLog(string strDocumentNo, string documentOCC, string strDocumentCode, string fileName)
        public ActionResult IVS240_DownloadPdfAndWriteLog(string k) //Modify by Jutarat A. on 04122012
        {
            Stream reportStream = null;                             //Add by Jutarat A. on 04122012

            try
            {
                //Modify by Jutarat A. on 04122012
                IVS240_ScreenParameter sParam = GetScreenObject <IVS240_ScreenParameter>(k);
                if (sParam.ResultDocument != null)
                {
                    doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                    {
                        DocumentNo   = sParam.ResultDocument.DocumentNo,   //strDocumentNo,
                        DocumentCode = sParam.ResultDocument.DocumentCode, //strDocumentCode,
                        DocumentOCC  = sParam.ResultDocument.DocumentOCC,  //documentOCC,
                        DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                        DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                    };

                    ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                    if (sParam.ResultStream != null)
                    {
                        reportStream        = sParam.ResultStream;
                        sParam.ResultStream = null;
                    }
                    else
                    {
                        IDocumentHandler handlerDoc = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                        reportStream = handlerDoc.GetDocumentReportFileStream(sParam.ResultDocument.FilePath); //(fileName);
                    }
                }
                //End Modify

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        public ActionResult ISR010_GetNewInstallationSlip(string strSlipNo)
        {
            IReportHandler            reportHandler = ServiceContainer.GetService <IReportHandler>() as IReportHandler;
            List <RPTNewRentalSlipDo> rptList       = reportHandler.GetRptNewRentalSlipReport(strSlipNo);

            IDocumentHandler            dochandler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
            List <tbm_DocumentTemplate> dLst       = dochandler.GetDocumentTemplateByDocumentCode(DocumentCode.C_DOCUMENT_CODE_NEW_INSTALL_SLIP_RENTAL);

            ReportDocument rptH = new ReportDocument();
            //string path = ReportUtil.GetReportTemplatePath("ISR010_NewInstallationSlip.rpt");
            string path = ReportUtil.GetReportPath("Reports/ISR010_NewInstallationSlip.rpt", Server.MapPath("/"));

            rptH.Load(path);

            List <RPTNewRentalSlipDo> lst = new List <RPTNewRentalSlipDo>();

            if (rptList != null && rptList.Count > 0)
            {
                lst.Add(rptList[0]);

                if (dLst.Count > 0)
                {
                    lst[0].DocumentNameEN  = dLst[0].DocumentNameEN;
                    lst[0].DocumentVersion = dLst[0].DocumentVersion;
                }
            }
            else
            {
                rptList.Add(new RPTNewRentalSlipDo());
            }

            rptH.SetDataSource(lst);
            rptH.Subreports["Page1"].SetDataSource(rptList);
            rptH.Subreports["Page2"].SetDataSource(rptList);
            rptH.Subreports["Page3"].SetDataSource(rptList);

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

            rptH.Close();

            return(File(stream, "application/pdf"));
        }
        public ActionResult ISR090_GetRptInstallCompleteConfirmData(string strSlipNo)
        {
            strSlipNo = "401029201112043";

            IReportHandler reportHandler        = ServiceContainer.GetService <IReportHandler>() as IReportHandler;
            List <RPTInstallCompleteDo> rptList = reportHandler.GetRptInstallCompleteConfirmData(strSlipNo);

            IDocumentHandler            dochandler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
            List <tbm_DocumentTemplate> dLst       = dochandler.GetDocumentTemplateByDocumentCode(DocumentCode.C_DOCUMENT_CODE_INSTALL_COMPLETE_CONFIRM);

            ReportDocument rptH = new ReportDocument();

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

            rptH.Load(path);

            List <RPTInstallCompleteDo> lst = new List <RPTInstallCompleteDo>();
            int i = 0;

            foreach (RPTInstallCompleteDo rptDataRow in rptList)
            {
                lst.Add(rptDataRow);
                if (dLst.Count > 0)
                {
                    lst[i].DocumentNameEN  = dLst[0].DocumentNameEN;
                    lst[i].DocumentVersion = dLst[0].DocumentVersion;
                }
                i++;
            }

            rptH.SetDataSource(lst);
            rptH.SetParameterValue("C_RENTAL_INSTALL_TYPE_REMOVE_ALL", RentalInstallationType.C_RENTAL_INSTALL_TYPE_REMOVE_ALL);
            rptH.SetParameterValue("C_SALE_INSTALL_TYPE_REMOVE_ALL", SaleInstallationType.C_SALE_INSTALL_TYPE_REMOVE_ALL);


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

            rptH.Close();

            return(File(stream, "application/pdf"));
        }
		private async Task ApplyResponseContent(HttpResponse response, IDocumentHandler handler)
		{
			//TODO: update response.ContentLength
			//https://github.com/aspnet/vsweb-docs/blob/aa6db2a87ed91214509382684d0a093945539dc8/src/app_code/PageSystem.cs#L73

			using (var content = handler.Open())
			{
				response.ContentLength = _layoutHead.Length + content.Length + _layoutTail.Length;
				await response.Body.WriteAsync(_layoutHead);
				await content.ContentStream.CopyToAsync(response.Body);
				await response.Body.WriteAsync(_layoutTail);
			}
		}
		private void ApplyResponseHeaders(HttpResponse response, IDocumentHandler handler)
		{
			response.ContentType = "text/html";
			response.StatusCode = handler.StatusCode;
			var headers = response.GetTypedHeaders();
			headers.LastModified = handler.LastModified;
			headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue()
			{
				MaxAge = _options.CacheMaxAge,
				Public = true
			};
		}
        /// <summary>
        /// 注销文档处理器
        /// </summary>
        /// <param name="handler">文档处理器.</param>
        public void UnRegister(IDocumentHandler handler)
        {
            Guard.ArgumentNotNull(handler, "DocumentHandler");

            handler.Enter -= OnEnter;
            handler.Leave -= OnLeave;
        }
 private void DocumentActivated(object sender, EventArgs e)
 {
     ActiveDocument = (IDocumentHandler)sender;
 }
 private void OnLeave(object sender, EventArgs e)
 {
     activeDocument = null;
     UpdateCommandStatus();
 }
        private void OnEnter(object sender, EventArgs e)
        {
            Microsoft.Practices.CompositeUI.Utility.Guard.TypeIsAssignableFromType(sender.GetType(), typeof(IDocumentHandler), "sender");

            activeDocument = (IDocumentHandler)sender;
            UpdateCommandStatus();
        }
 private void InitializeDocument(IDocumentHandler document)
 {
     document.DocumentActivated += new EventHandler(DocumentActivated);
     document.DocumentDeactivated += new EventHandler(DocumentDeactivated);
     document.Disposed += new EventHandler(DocumentDisposed);
     ActiveDocument = document;
 }
 private void DocumentDisposed(object sender, EventArgs e)
 {
     IDocumentHandler document = (IDocumentHandler)sender;
     document.DocumentActivated -= DocumentActivated;
     document.DocumentDeactivated -= DocumentDeactivated;
     document.Disposed -= DocumentDisposed;
     ActiveDocument = null;
 }
 private void DocumentDeactivated(object sender, EventArgs e)
 {
     ActiveDocument = null;
 }