public override object PrepareDataSource(FeedReportInputModel inputModel, ReportingFormat format, IServiceLocatorSchool serviceLocator, IServiceLocatorMaster masterLocator) { var baseData = PrepareBaseReportData(inputModel, serviceLocator); var settings = inputModel.Settings; var annType = inputModel.Settings.LessonPlanOnly ? AnnouncementTypeEnum.LessonPlan : (AnnouncementTypeEnum?)inputModel.AnnouncementType; var anns = serviceLocator.AnnouncementFetchService.GetAnnouncementDetailses(settings.StartDate, settings.EndDate, inputModel.ClassId, inputModel.Complete, annType); //hide hidden activities if not included if (!settings.IncludeHiddenActivities) { anns = anns.Where(x => x.ClassAnnouncementData == null || x.ClassAnnouncementData.VisibleForStudent).ToList(); } // hide attachments and applications if not included if (!settings.IncludeAttachments) { anns = anns.Select(x => { x.AnnouncementAttachments = new List <AnnouncementAttachment>(); x.AttachmentNames = new List <string>(); x.ApplicationCount = 0; x.AnnouncementApplications = new List <AnnouncementApplication>(); return(x); }).ToList(); } // hide hidden attributes if not included if (!settings.IncludeHiddenAttributes) { anns = anns.Select(x => { x.AnnouncementAttributes = x.AnnouncementAttributes.Where(a => a.VisibleForStudents).ToList(); return(x); }).ToList(); } //Get apps with images var appIds = anns.SelectMany(x => x.AnnouncementApplications.Select(y => y.ApplicationRef)).Distinct().ToList(); var apps = masterLocator.ApplicationService.GetApplicationsByIds(appIds); IDictionary <Guid, byte[]> appsImages = new Dictionary <Guid, byte[]>(); foreach (var app in apps) { if (appsImages.ContainsKey(app.Id)) { continue; } var image = masterLocator.ApplicationPictureService.GetPicture(app.BigPictureRef.Value, 170, 110); appsImages.Add(app.Id, image); } var fromDate = settings.StartDate ?? serviceLocator.Context.SchoolYearStartDate; var toDate = settings.EndDate ?? serviceLocator.Context.SchoolYearEndDate; return(FeedDetailsExportModel.Create(baseData.Person, baseData.SchoolName, baseData.SchoolYearName, serviceLocator.Context.NowSchoolTime, fromDate, toDate, anns, baseData.Classes, baseData.DayTypes, baseData.Staffs, apps, appsImages)); }
public override object PrepareDataSource(FeedReportInputModel inputModel, ReportingFormat format, IServiceLocatorSchool serviceLocator, IServiceLocatorMaster masterLocator) { var baseData = PrepareBaseReportData(inputModel, serviceLocator); var feedSettings = new FeedSettingsInfo { AnnouncementType = inputModel.Settings.LessonPlanOnly ? (int)AnnouncementTypeEnum.LessonPlan : inputModel.AnnouncementType, FromDate = inputModel.Settings.StartDate, ToDate = inputModel.Settings.EndDate }; //bool isForAdminPortal = BaseSecurity.IsDistrictAdmin(serviceLocator.Context) && !inputModel.ClassId.HasValue; //var anns = isForAdminPortal // ? serviceLocator.AnnouncementFetchService.GetAnnouncementsForAdminFeed(inputModel.Complete, null, feedSettings) // : serviceLocator.AnnouncementFetchService.GetAnnouncementsForFeed(inputModel.Complete, inputModel.ClassId, feedSettings); var anns = serviceLocator.AnnouncementFetchService.GetAnnouncementDetailses(feedSettings.FromDate, feedSettings.ToDate, inputModel.ClassId, inputModel.Complete, feedSettings.AnnouncementTypeEnum); //hide hidden activities if (!inputModel.Settings.IncludeHiddenActivities) { anns = anns.Where(x => x.ClassAnnouncementData == null || x.ClassAnnouncementData.VisibleForStudent).ToList(); } ////remove standards if groupByStandards is not selected //if (!inputModel.Settings.GroupByStandards) // anns = anns.Select(x => // { // x.AnnouncementStandards = new List<AnnouncementStandardDetails>(); // return x; // }).ToList(); var fromDate = inputModel.Settings.StartDate ?? serviceLocator.Context.SchoolYearStartDate; var toDate = inputModel.Settings.EndDate ?? serviceLocator.Context.SchoolYearEndDate; return(ShortFeedExportModel.Create(baseData.Person, baseData.SchoolName, baseData.SchoolYearName, serviceLocator.Context.NowSchoolTime, fromDate, toDate, baseData.Classes, baseData.Staffs, baseData.DayTypes, anns, inputModel.Settings.GroupByStandards)); }
public byte[] Render(object dataSet, string reportDefinition, ReportingFormat format, int?page) { var report = new LocalReport { ReportPath = reportDefinition }; var dataSource = new ReportDataSource("MainDataSet", dataSet); report.DataSources.Add(dataSource); string deviceInfo = "<DeviceInfo>" + " <PageWidth>9in</PageWidth>" + " <PageHeight>12in</PageHeight>" + " <MarginTop>0.05in</MarginTop>" + " <MarginLeft>0.05in</MarginLeft>" + " <MarginRight>0.05in</MarginRight>" + " <MarginBottom>0.05in</MarginBottom>" + "</DeviceInfo>"; string fmt = format.AsString(); var res = report.Render(fmt, deviceInfo); return(res); }
public static string AsFileExtension(this ReportingFormat format) { switch (format) { case ReportingFormat.Pdf: return(EXT_PDF); case ReportingFormat.Csv: return(EXT_CSV); case ReportingFormat.Excel: return(EXT_XLS); case ReportingFormat.Tiff: return(EXT_TIFF); case ReportingFormat.Html: return(EXT_HTML); case ReportingFormat.Xml: return(EXT_XML); case ReportingFormat.Json: return(EXT_JSON); case ReportingFormat.Word: return(EXT_DOC); default: throw new Exception(ChlkResources.ERR_INVALID_REPORT_FORMAT); } }
public static string AsString(this ReportingFormat format) { if (format == ReportingFormat.Excel) { return(EXCEL); } if (format == ReportingFormat.Pdf) { return(PDF); } if (format == ReportingFormat.Word) { return(WORD); } if (format == ReportingFormat.Csv) { return(CSV); } if (format == ReportingFormat.Json) { return(JSON); } throw new Exception(ChlkResources.ERR_INVALID_REPORT_FORMAT); }
public abstract object PrepareDataSource(FeedReportInputModel settings, ReportingFormat format, IServiceLocatorSchool serviceLocator, IServiceLocatorMaster masterLocator);
private ActionResult DownloadReportFile(byte[] report, string reportFileName, ReportingFormat formatType) { Response.AppendCookie(new HttpCookie("chlk-iframe-ready", Guid.NewGuid().ToString())); var extension = formatType.AsFileExtension(); var fileName = $"{reportFileName}.{extension}"; MasterLocator.UserTrackingService.CreatedReport(Context.Login, reportFileName); return(File(report, MimeHelper.GetContentTypeByExtension(extension), fileName)); }
private ActionResult Report(Func <byte[]> reportAction, string reportFileName, ReportingFormat formatType , Func <byte[], string, ReportingFormat, ActionResult> loadAction) { try { var res = reportAction(); return(loadAction(res, reportFileName, formatType)); } catch (LocalProcessingException exception) { return(HandlReportProcessingException(exception)); } catch (Exception exception) { return(HandleAttachmentException(exception)); } }