davidbitton

Untitled

Nov 14th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1.             var query =
  2.                 from file in SelectedFiles.ToObservable()
  3.                 from document in Observable.FromAsyncPattern<int, string, DocumentType, Document>(_dataService.BeginCreateEmptyDocument, _dataService.EndCreateEmptyDocument)(SelectedCompany.Id, file.FullName, SelectedDocumentType)
  4.                 select Tuple.Create(document, false);
  5.  
  6.             if (verify) {
  7.                 query =
  8.                     from r1 in query
  9.                     from exists in Observable.FromAsyncPattern<Document, bool>(_dataService.BeginVerifyDocument, _dataService.EndVerifyDocument)(r1.Item1)
  10.                     select Tuple.Create(r1.Item1, exists);
  11.             }
  12.  
  13.             query
  14.                 .Merge()
  15.                 .Aggregate(new List<Document>(), (list, result) => {
  16.                     if (result.Item2 == false)
  17.                         list.Add(result.Item1);
  18.                     return list;
  19.                 });
  20.  
  21.  
  22.             //var documents = new List<Document>();
  23.             List<Document> documents = null;
  24.             query
  25.                 .ObserveOnDispatcher()
  26.                 .Subscribe(
  27.                 i => {
  28.                     //documents.Add(i); UpdateStatus(String.Format("Created new Document for {0}", i.Path));
  29.                     documents = i;
  30.                 },
  31.                 e => UpdateStatus("Error parsing filename.", e),
  32.                 () => {
  33.                     if (documents == null) return;
  34.                     _uiService.ShowView(ViewNames.DocumentsListView, documents);
  35.                 }
  36.             );
  37.  
Advertisement
Add Comment
Please, Sign In to add comment