internal async void OnCurrentPreviousDocumentIDChanged(object sender, NotificationEventArgs <string> e) { using (PreviousDocumentRepository ctx = new PreviousDocumentRepository()) { CurrentPreviousDocument = await ctx.GetPreviousDocument(e.Data).ConfigureAwait(continueOnCapturedContext: false); } NotifyPropertyChanged(m => CurrentPreviousDocument); }
public async Task SelectAll() { IEnumerable <PreviousDocument> lst = null; using (var ctx = new PreviousDocumentRepository()) { lst = await ctx.GetPreviousDocumentsByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false); } SelectedPreviousDocuments = new ObservableCollection <PreviousDocument>(lst); }
public IList <PreviousDocument> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount) { try { if (FilterExpression == null) { FilterExpression = "All"; } using (var ctx = new PreviousDocumentRepository()) { var r = ctx.LoadRange(startIndex, count, FilterExpression, navExp, IncludesLst); overallCount = r.Result.Item2; return(r.Result.Item1.ToList()); } } catch (Exception ex) { StatusModel.Message(ex.Message); overallCount = 0; return(new List <PreviousDocument>()); } }
// Send to Excel Implementation public async Task Send2Excel() { IEnumerable <PreviousDocument> lst = null; using (var ctx = new PreviousDocumentRepository()) { lst = await ctx.GetPreviousDocumentsByExpressionNav(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 <PreviousDocumentExcelLine, List <PreviousDocumentExcelLine> > { dataToPrint = lst.Select(x => new PreviousDocumentExcelLine { id = x.id, CNumber = x.CNumber, RegistrationDate = x.RegistrationDate, IsManuallyAssessed = x.IsManuallyAssessed, ReferenceNumber = x.ReferenceNumber, EffectiveRegistrationDate = x.EffectiveRegistrationDate, TotalValue = x.TotalValue, AllocatedValue = x.AllocatedValue, PiValue = x.PiValue, DoNotAllocate = x.DoNotAllocate, Description = x.Description, BLNumber = x.BLNumber, Lines = x.Lines, DocumentType = x.DocumentType }).ToList() }; using (var sta = new StaTaskScheduler(numberOfThreads: 1)) { await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false); } }