/// <summary> /// BuildReportFromList in ListPrintHelper /// </summary> /// <param name="options"></param> /// <param name="listId"></param> /// <param name="userContext"></param> /// <param name="userProfile"></param> /// <param name="_listLogic"></param> /// <param name="_profileLogic"></param> /// <param name="_elRepo"></param> /// <returns></returns> public static Stream BuildReportFromList(PrintListModel options, ListType type, long listId, UserSelectedContext userContext, UserProfile userProfile, IListService listService, IUserProfileLogic _profileLogic, IEventLogRepository _elRepo) { if (!string.IsNullOrEmpty(options.Paging.Terms)) { //Build filter options.Paging.Filter = new FilterInfo() { Field = "ItemNumber", FilterType = "contains", Value = options.Paging.Terms, Condition = "||", Filters = new List <FilterInfo>() { new FilterInfo() { Condition = "||", Field = "Label", Value = options.Paging.Terms, FilterType = "contains" }, new FilterInfo() { Condition = "||", Field = "Name", Value = options.Paging.Terms, FilterType = "contains" } } }; } options.Paging.Size = int.MaxValue; options.Paging.From = 0; if (options.Paging.Sort.Count == 1 && options.Paging.Sort[0].Field == null) { options.Paging.Sort = new List <SortInfo>(); } ListModel list = listService.ReadList(userProfile, userContext, type, listId, options.ShowPrices); var NotesHash = listService.GetNotesHash(userContext); foreach (var item in list.Items) { if (NotesHash.ContainsKey(item.ItemNumber)) { item.Notes = NotesHash[item.ItemNumber].Notes; } } if (list == null) { return(null); } ListModel printlist = list.Clone(); printlist.ListId = 0; if (options.Filter != null) { printlist.Items = printlist.Items.AsQueryable() .Filter(options.Filter, null) .ToList(); } StringBuilder sortinfo = new StringBuilder(); foreach (SortInfo si in options.Paging.Sort) { if (sortinfo.Length > 0) { sortinfo.Append(";"); } sortinfo.Append(si.Field); sortinfo.Append(","); sortinfo.Append(si.Order); } printlist.Items = SortOrderItems(sortinfo.ToString(), printlist.Items); int ind = 1; foreach (ListItemModel item in printlist.Items) { item.Position = ind++; } ListReportModel printModel = printlist.ToReportModel(); Customer customer = _profileLogic.GetCustomerByCustomerNumber(userContext.CustomerId, userContext.BranchId); ReportViewer rv = new ReportViewer(); rv.ProcessingMode = ProcessingMode.Local; Assembly assembly = Assembly.Load("Keithlink.Svc.Impl"); string rptName = ChooseReportFromOptions(options, userContext, customer); Stream rdlcStream = assembly.GetManifestResourceStream(rptName); rv.LocalReport.LoadReportDefinition(rdlcStream); rv.LocalReport.SetParameters (MakeReportOptionsForPrintListReport(options, printModel.Name, userContext, customer)); GatherInfoAboutItems(type, listId, options, printModel, userContext, userProfile, customer, listService); rv.LocalReport.DataSources.Add(new ReportDataSource("ListItems", printModel.Items)); string deviceInfo = (options.Landscape) ? KeithLink.Svc.Core.Constants.SET_REPORT_SIZE_LANDSCAPE : KeithLink.Svc.Core.Constants.SET_REPORT_SIZE_PORTRAIT; byte[] bytes = rv.LocalReport.Render("PDF", deviceInfo); Stream stream = new MemoryStream(bytes); return(stream); }