public async Task SelectAll() { IEnumerable <PreviousDocumentItem> lst = null; using (var ctx = new PreviousDocumentItemRepository()) { lst = await ctx.GetPreviousDocumentItemsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false); } SelectedPreviousDocumentItems = new ObservableCollection <PreviousDocumentItem>(lst); }
// Send to Excel Implementation public async Task Send2Excel() { IEnumerable <PreviousDocumentItem> lst = null; using (var ctx = new PreviousDocumentItemRepository()) { lst = await ctx.GetPreviousDocumentItemsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false); } if (lst == null || !lst.Any()) { MessageBox.Show("No Data to Send to Excel"); return; } var s = new ExportToExcel <PreviousDocumentItemExcelLine, List <PreviousDocumentItemExcelLine> > { dataToPrint = lst.Select(x => new PreviousDocumentItemExcelLine { Amount_deducted_from_licence = x.Amount_deducted_from_licence, Licence_number = x.Licence_number, Free_text_1 = x.Free_text_1, Free_text_2 = x.Free_text_2, LineNumber = x.LineNumber, IsAssessed = x.IsAssessed, DPQtyAllocated = x.DPQtyAllocated, DFQtyAllocated = x.DFQtyAllocated, EntryTimeStamp = x.EntryTimeStamp, AttributeOnlyAllocation = x.AttributeOnlyAllocation, DoNotAllocate = x.DoNotAllocate, DoNotEX = x.DoNotEX, Item_price = x.Item_price, ItemNumber = x.ItemNumber, TariffCode = x.TariffCode, DutyLiability = x.DutyLiability, Total_CIF_itm = x.Total_CIF_itm, Freight = x.Freight, Statistical_value = x.Statistical_value, PiQuantity = x.PiQuantity, Description_of_goods = x.Description_of_goods, Commercial_Description = x.Commercial_Description, Suppplementary_unit_code = x.Suppplementary_unit_code, ItemQuantity = x.ItemQuantity, Number = x.Number, DocumentType = x.DocumentType }).ToList() }; using (var sta = new StaTaskScheduler(numberOfThreads: 1)) { await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false); } }