Exemplo n.º 1
0
        public async void ToolsDownloadProjectsClick()
        {
            try
            {
                var downloader = new ProjectDownloader(_proteinService);
                await downloader.ExecuteAsyncWithProgress(true);

                if (downloader.Result != null)
                {
                    var proteinChanges = downloader.Result.Where(x => x.Result != ProteinDictionaryChangeResult.NoChange).ToList();
                    if (proteinChanges.Count > 0)
                    {
                        _retrievalModel.RunClientRetrieval();
                        using (var dlg = new ProteinLoadResultsDialog())
                        {
                            dlg.DataBind(proteinChanges);
                            dlg.ShowDialog(_view);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _messageBoxView.ShowError(ex.Message, Core.Application.NameAndVersion);
            }
        }
Exemplo n.º 2
0
        public void ToolsDownloadProjectsClick()
        {
            var downloader = ServiceLocator.Resolve<IProjectSummaryDownloader>();
             // Clear the Project Not Found Cache and Last Download Time
             _proteinDictionary.ClearProjectsNotFoundCache();
             // Execute Asynchronous Download
             var projectDownloadView = ServiceLocator.Resolve<IProgressDialogView>("ProjectDownloadDialog");
             projectDownloadView.OwnerWindow = _view;
             projectDownloadView.ProcessRunner = downloader;
             projectDownloadView.UpdateMessage(_prefs.Get<string>(Preference.ProjectDownloadUrl));
             projectDownloadView.Process();

             if (downloader.Exception != null)
             {
            _logger.Error(downloader.Exception.Message, downloader.Exception);
            _messageBoxView.ShowError(_view, downloader.Exception.Message, Core.Application.NameAndVersion);
            return;
             }

             IEnumerable<ProteinLoadInfo> loadInfo;
             try
             {
            loadInfo = _proteinDictionary.Load(downloader.DownloadFilePath);
            foreach (var info in loadInfo.Where(info => !info.Result.Equals(ProteinLoadResult.NoChange)))
            {
               Logger.Info(info.ToString());
            }
            _proteinDictionary.Write();
            //_proteinDictionary.Write(Path.Combine(_prefs.ApplicationDataFolderPath, "ProjectInfo.xml"), new Core.Serializers.XmlFileSerializer<List<Protein>>());
             }
             catch (Exception ex)
             {
            _logger.ErrorFormat(ex, "{0}", ex.Message);
            return;
             }

             if (loadInfo.Where(x => !x.Result.Equals(ProteinLoadResult.NoChange)).Count() != 0)
             {
            _retrievalLogic.QueueNewRetrieval();
            using (var dlg = new ProteinLoadResultsDialog())
            {
               dlg.DataBind(loadInfo);
               dlg.ShowDialog(_view);
            }
             }
        }
Exemplo n.º 3
0
      public void ToolsDownloadProjectsClick()
      {
         _proteinService.ResetRefreshParameters();

         var progress = new TaskSchedulerProgress<harlam357.Core.ComponentModel.ProgressChangedEventArgs>();
         var projectDownloadView = _viewFactory.GetProjectDownloadDialog();
         projectDownloadView.Progress = progress;

         Task<IEnumerable<ProteinLoadInfo>> refreshTask = null;
         projectDownloadView.Shown += (s, args) =>
         {
            var uiTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
            refreshTask = _proteinService.RefreshAsync(progress);
            refreshTask
               .ContinueWith(t => _messageBoxView.ShowError(projectDownloadView, t.Exception.Flatten().InnerException.Message, Core.Application.NameAndVersion),
                     CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, uiTaskScheduler)
               .ContinueWith(t => projectDownloadView.Close(), uiTaskScheduler);
         };
         projectDownloadView.ShowDialog(_view);
         _viewFactory.Release(projectDownloadView);

         if (refreshTask.Status == TaskStatus.RanToCompletion && refreshTask.Result != null)
         {
            var proteinChanges = refreshTask.Result.Where(x => x.Result != ProteinLoadResult.NoChange).ToList();
            if (proteinChanges.Count > 0)
            {
               _retrievalModel.RunClientRetrieval();
               using (var dlg = new ProteinLoadResultsDialog())
               {
                  dlg.DataBind(proteinChanges);
                  dlg.ShowDialog(_view);
               }
            }
         }
      }