Click or drag to resize

ExtensionGetVariableFromDb Method

Gets the value of the vault variable for the specified file.

Namespace:  CADSharpTools.PDM
Assembly:  CADSharpTools.PDM (in CADSharpTools.PDM.dll) Version: 1.4.16.0 (1.4.16)
Syntax
public static MethodReturn<Object> GetVariableFromDb(
	this IEdmFile5 file,
	string variable,
	string configurationName = "@"
)

Parameters

file
Type: IEdmFile5
File object.
variable
Type: SystemString
Vault variable name.
configurationName (Optional)
Type: SystemString
Configuration name. Default is "@".

Return Value

Type: MethodReturnObject

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEdmFile5. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
CADSharpToolsPDMExceptionThrown when unable to get the parent folder of the specified file object.
Remarks
Use this method to get data from files that are not cached (have no local copy) instead of using GetDataCardVariable(IEdmFile5, String, String).
Examples
This example shows how to login to the vault and get the value of a vault variable called "Part Number" for the first file.
public enum EdmLoginFlags
{
    Nothing,
    WebClient
}

public static void Example()
{
    //create vault object 
    var swPDMVault = new EdmVault5();
    var swPDMVaultEx = swPDMVault as IEdmVault13;

    //required per PDM EULA in out-of-process applications              
    swPDMVaultEx.LoginEx("Admin", "****", "CADSharp LLC", (int)EdmLoginFlags.Nothing);

    // get root folder 
    var swPDMRootFolder = swPDMVaultEx.RootFolder;

    // get first file position
    var swPDMFirstFilePos = swPDMRootFolder.GetFirstFilePosition();
    if (swPDMFirstFilePos.IsNull == false)
    {
        var swPDMFirstFile = swPDMRootFolder.GetNextFile(swPDMFirstFilePos);

        // get the part number of the first file 
        var variableReturn = swPDMFirstFile.GetVariableFromDb("Part Number");
        if (variableReturn.IsError)
        {
            Debug.Print(variableReturn.Error);
            return;
        }

        var partNumberValue = variableReturn.Value.ToString();
        Debug.Print($"Part Number variable value: {partNumberValue}");
    }
    else
    {
        Debug.Print($"Vault has no files at the root folder.");
    }
}
See Also