public bool AbortJob(Job j) { lock (QueuedJobs) { Trace.TraceInformation(string.Format("Job Aborted in local pool: {0} {1}", j.Id, j.Title)); //Find job in queue and remove it if present bool foundJob = QueuedJobs.Remove(j); if (foundJob) { j.Status = Job.StatusEnum.FailedAbortByUser; return(true); } else { // Job not in queue; means it must be running var abortJobEvent = GetAbortJobEvent(j); if (abortJobEvent != null) { abortJobEvent.Set(); return(true); } else { Trace.TraceError("Attempted to abort job that appears to not be running"); return(false); } } } }
public void CheckJobStatus() { try { var client = BrightstarService.GetClient(Store.Source.ConnectionString); var inProgress = QueuedJobs.Where(j => !j.Completed).ToList(); if (inProgress.Any()) { foreach (var job in inProgress) { job.RefreshStatus(client, Store.Location); } Thread.Sleep(1000); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(this.CheckJobStatus)); } else { _monitorStarted = false; } } catch (Exception) { ProgressText = "Error retrieving job status information from server. This may indicate a networking problem or that the server has stopped running."; } }
public void EnqueueJob(Job j) { Trace.TraceInformation(string.Format("JobEnqueued in local pool: {0} {1}", j.Id, j.Title)); QueuedJobs.AddLast(j); j.Status = Job.StatusEnum.QueuedLocal; JobAdded.Set(); }
private void StartRemoteImport() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); var importJob = client.StartImport(Store.Location, ImportFileName); QueuedJobs.Add(new ImportJobViewModel(ImportFileName, importJob, false)); if (!_monitorStarted) { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); } }
private void LocalImportContinuation(MessageBoxResult dialogResult = MessageBoxResult.Yes) { try { if (dialogResult == MessageBoxResult.Yes) { var ext = MimeTypesHelper.GetTrueFileExtension(_importFileName); bool isGZipped = ext.EndsWith(MimeTypesHelper.DefaultGZipExtension); string lines; var fileTypeDefinition = MimeTypesHelper.GetDefinitionsByFileExtension(ext).FirstOrDefault(d => d.CanParseRdf); var rdfReader = fileTypeDefinition == null ? null : fileTypeDefinition.GetRdfParser(); if (rdfReader == null || rdfReader is NTriplesParser || rdfReader is NQuadsParser) { // We can't determine the file type, or it is NQuads or NTriples if (isGZipped) { using (var fileStream = new FileStream(_importFileName, FileMode.Open)) { var gZipStream = new GZipStream(fileStream, CompressionMode.Decompress); var reader = new StreamReader(gZipStream); lines = reader.ReadToEnd(); } } else { lines = File.ReadAllText(_importFileName); } } else { using (var textWriter = new StringWriter()) { try { var nQuadsFormatter = new NQuadsFormatter(); var writeThroughHandler = new WriteThroughHandler(nQuadsFormatter, textWriter); rdfReader.Load(writeThroughHandler, _importFileName); lines = textWriter.ToString(); } catch (Exception ex) { Messenger.Default.Send(new ShowDialogMessage( Strings.ParseErrorTitle, string.Format(Strings.ParseErrorDescription, _importFileName, ex.Message), MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); return; } } } var client = BrightstarService.GetClient(Store.Source.ConnectionString); var graphUri = !string.IsNullOrWhiteSpace(ImportGraphName) ? ImportGraphName : Constants.DefaultGraphUri; var transactionJob = client.ExecuteTransaction(Store.Location, new UpdateTransactionData { InsertData = lines, DefaultGraphUri = graphUri }, waitForCompletion: false); QueuedJobs.Add(new ImportJobViewModel(ImportFileName, transactionJob, true)); if (_monitorStarted) { return; } _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); _monitorStarted = true; } } catch (OutOfMemoryException) { Messenger.Default.Send(new ShowDialogMessage(Strings.ParseErrorTitle, Strings.ImportFileTooLarge, MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } }