/// <summary> /// Execute a SPARQL Update expression against a store /// </summary> /// <param name="storeName">The name of the store to be updated</param> /// <param name="updateExpression">The SPARQL Update expression to be applied</param> /// <param name="waitForCompletion">If set to true, the method will block until the transaction completes</param> /// <returns>A <see cref="JobInfo"/> instance for monitoring the status of the job</returns> public IJobInfo ExecuteUpdate(string storeName, string updateExpression, bool waitForCompletion = true) { try { if (!waitForCompletion) { var jobId = _serverCore.ExecuteUpdate(storeName, updateExpression); return(new JobInfoWrapper(new JobInfo { JobId = jobId.ToString(), JobPending = true })); } else { var jobId = _serverCore.ExecuteUpdate(storeName, updateExpression); JobExecutionStatus status = _serverCore.GetJobStatus(storeName, jobId.ToString()); while (status.JobStatus != JobStatus.CompletedOk && status.JobStatus != JobStatus.TransactionError) { Thread.Sleep(50); status = _serverCore.GetJobStatus(storeName, jobId.ToString()); } return(new JobInfoWrapper(new JobInfo { JobId = jobId.ToString(), StatusMessage = status.Information, JobCompletedOk = (status.JobStatus == JobStatus.CompletedOk), JobCompletedWithErrors = (status.JobStatus == JobStatus.TransactionError) })); } } catch (Exception ex) { Logging.LogError(BrightstarEventId.ServerCoreException, "Error queing SPARQL update {0} {1}", storeName, updateExpression); throw new BrightstarClientException("Error queing SPARQL update in store " + storeName + ". " + ex.Message, ex); } }