public ActionResult GetFileReport(int id, string startDate, string endDate, string fullName, string fileType, string officeNum)
        {
            try
            {
                var dateRange       = DateTime.Parse(startDate).ToString("MM/dd/yyyy") + " to " + DateTime.Parse(endDate).ToString("MM/dd/yyyy");
                var scheduledReport = ReportFactory.CreateReportWithManualDispose <ScheduledRecallReport>();
                var stream          = new Api.PatientReportsController().GetReportContent(id, fileType, dateRange, fullName, officeNum, scheduledReport);
                if (stream != null)
                {
                    this.Response.Clear();
                    this.Response.ClearHeaders();
                    this.Response.Buffer = true;
                    if (fileType == "EXCEL")
                    {
                        Response.ContentType = "application/vnd.ms-excel";
                        Response.AddHeader("content-disposition", "attachment; filename=RecallDetails.xls");
                    }
                    else
                    {
                        this.Response.ContentType = "application/pdf";
                        this.Response.AppendHeader(
                            "Content-Disposition", fileType == "PDF" ? "inline; filename=RecallDetails.pdf" : "inline; filename=SurveyDetails.pdf");
                    }

                    this.Response.BinaryWrite(stream.ToArray());
                    this.Response.Flush();
                    this.Response.End();
                }
                else
                {
                    this.Response.Clear();
                    this.Response.Buffer = true;
                    this.Response.AddHeader("content-disposition", "attachment; filename=ExportReports.txt");
                    this.Response.ContentType = "application/octet-stream";
                    const string Msg = "This report has timed out, please re-run the report. If the problem continues, notify customer support.";
                    using (var stream2 = Msg.ToStream())
                    {
                        stream2.CopyTo(this.Response.OutputStream);
                    }

                    this.Response.End();

                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error(string.Format("GetReportContent failed for id {0} Office {1} fullname {2} filetype {3} daterange {4} ", id, officeNum, fullName, fileType, dateRange));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetFileReport generated exception - " + ex);
            }

            return(null);
        }
        public ActionResult GeneratePrintableDocument(int recallId, string officeNum, int printFormat)
        {
            try
            {
                var contents = new Api.PatientReportsController().GeneratePrintableDocument(recallId, officeNum, printFormat);
                this.Response.Clear();
                this.Response.ClearHeaders();
                this.Response.ContentType = "application/pdf";
                this.Response.OutputStream.Write(contents, 0, contents.Length);
                this.Response.Flush();
                this.Response.End();
            }
            catch (Exception ex)
            {
                Logger.Error("GetLabelsReport generated exception - " + ex);
            }

            return(null);
        }
        public ActionResult GetLabelsReport(int id, string officeNum)
        {
            ////try
            ////{
            var uploadsLocation = this.Server.MapPath("~/App_Data/Uploads");

            if (!Directory.Exists(uploadsLocation))
            {
                Directory.CreateDirectory(uploadsLocation);
                var di   = new DirectoryInfo(uploadsLocation);
                var fsar = new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow);
                var ds   = di.GetAccessControl();
                ds.AddAccessRule(fsar);
                di.SetAccessControl(ds);
            }

            var pdfFile = this.Server.MapPath("~/App_Data/Uploads/" + DateTime.Now.ToString("MMddyyhhmmssfff") + ".pdf");
            var content = new Api.PatientReportsController().GetPrintLabels(id, officeNum, pdfFile);

            if (content != null)
            {
                this.Response.Clear();
                this.Response.ClearHeaders();
                this.Response.ContentType = "application/pdf";
                this.Response.AppendHeader("Content-Disposition", "inline; filename=Document.pdf");
                this.Response.OutputStream.Write(content, 0, content.Length);
                this.Response.Flush();
                this.Response.End();
            }
            ////}
            ////catch (Exception ex)
            ////{
            ////    Logger.Error("GetLabelsReport generated exception - " + ex);
            ////}

            return(null);
        }