IQdvEnvironment Interface

Provides information about QDV environment.
Public Interface IQdvEnvironment
This language is not supported or no code example is available.
public interface IQdvEnvironment
This language is not supported or no code example is available.
Name Description
Public property GlobalErrors Gets read-only access to the old error handling mechanism in the API.
Public property InterfaceLocale Gets the current locale of the QDV user interface.
Public property IsQdvBeta Gets a value indicating whether the currently running QDV application is a beta version.
Public property QdvEdition Get the edition of the currently running QDV application.
Public property QdvVersion Get the version of the currently running QDV application.
Public property UserData Gets a collection of additional user-defined data for the current QDV session.
Top
Methods
 
Name Description
Public method GetDatabasePath(int) Returns the database path associated with the path number.
Public method GetLatestDatabaseInDirectory(string) For dated databases, returns the most recent database matching the passed database in the folder.
Public method GetLicenseInfo() Get the license information of the currently running QDV application.
Public method GetQdvTempFileName(string, string, bool) Gets a unique file name in the default QDV temporary location. It also creates the empty file.
Top
Remarks
 
You can obtain an instance of this interface from QdvManager.Environment property.
Example
 

The following example uses IQdvEnvironment to create a temporary copy of an estimate file. Then it opens the estimate from that copy and reads some data. This will prevent from any accidental changes in the original file and more importantly, it prevents problems if the estimate is already opened (and thus locked). When everything is finished, the estimate is closed. 

' The following code will inspect specified estimate. We don't want to modify the estimate,
 ' we only need to read some info from it. In such a case it is safer to open it in "read-only" mode.
 ' This is done by creating a tmp copy of the file and working with it.
 ' The file name of the estimate to be inspected.
 
 Dim estimateFileName As String = "C:\Sample_1.qdv"
 Dim estimate As IEstimate = Nothing
 
 ' Use IQdvEnvironment to get a tmp path.
 Dim tmpFileName As String = Context.QdvManager.Environment.GetQdvTempFileName(".qdv", "readonly_copy_")
 ' The tmpFileName is something like C:\Users\<USER>\AppData\Local\Temp\QDVTempFilesMain\readonly_copy_kqcc1fp5.qdv.
 
 Try
 
  ' Create a tmp copy of the estimate file. This will prevent from any changes in the original file
  ' and more importantly, it prevents problems if the estimate is already opened (and thus locked).
  If System.IO.File.Exists(estimateFileName) Then
   System.IO.File.Copy(estimateFileName, tmpFileName, True)
  End If
  
  ' Remove the read-only protection, if it was applied. Can happen if the original file had the read-only attribute.
  Dim attributes As System.IO.FileAttributes = System.IO.File.GetAttributes(tmpFileName)
  attributes = attributes And Not System.IO.FileAttributes.ReadOnly
  System.IO.File.SetAttributes(tmpFileName, attributes)
  
  ' Get the estimate instance with IEstimateFactory.
  estimate = Context.QdvManager.EstimateFactory.GetEstimate(tmpFileName)
  
  ' Get required data from the estimate. For example, get the number of all tasks.
  Dim taskCount As Integer = estimate.CurrentVersion.Wbs.GetTasksForScope("", True).Count
  MessageBox.Show("The number of tasks in the inspected estimate is " & taskCount)
  
 Finally
 
  ' When everything is done, don't forget to close the estimate.
  If estimate IsNot Nothing Then
   estimate.Close()
  End If
  ' There's no need to delete the tmp file created with GetQdvTempFileName
  ' because it is done automatically when QDV application is closed.
  
 End Try					
This language is not supported or no code example is available.
Version
 
Available since QDV 7.13.0001.

.NET Framework

Supported in: 4.8, 4.7, 4.6, 4.5.2

In this article

Definition