internal async void OnCurrentAsycudaDocumentIDChanged(object sender, NotificationEventArgs <string> e) { using (AsycudaDocumentRepository ctx = new AsycudaDocumentRepository()) { CurrentAsycudaDocument = await ctx.GetAsycudaDocument(e.Data).ConfigureAwait(continueOnCapturedContext: false); } NotifyPropertyChanged(m => CurrentAsycudaDocument); }
public async Task Send2Excel(string folder, AsycudaDocument doc) { if (doc != null) { using (var ctx = new AsycudaDocumentRepository()) { var doctype = await ctx.GetAsycudaDocument(doc.ASYCUDA_Id.ToString()).ConfigureAwait(false); if (doctype.DocumentType == "IM7") { return; } } } using (var sta = new StaTaskScheduler(numberOfThreads: 1)) { await Task.Factory.StartNew(() => { var s = new ExportToExcel <SaleReportLine, List <SaleReportLine> >(); s.StartUp(); try { folder = Path.GetDirectoryName(folder); var data = GetDocumentSalesReport(doc.ASYCUDA_Id).Result; if (data != null) { string path = Path.Combine(folder, !string.IsNullOrEmpty(doc.CNumber) ? doc.CNumber : doc.ReferenceNumber + ".xls"); s.dataToPrint = data.ToList(); s.SaveReport(path); } else { s.dataToPrint = new List <SaleReportLine>(); File.Create(Path.Combine(folder, doc.CNumber ?? doc.ReferenceNumber + ".xls")); } StatusModel.StatusUpdate(); } catch (Exception ex) { throw ex; } s.ShutDown(); }, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false); } }