1- using System ;
2- using System . Collections . Generic ;
1+ using System . Collections . Generic ;
32using System . Linq ;
43using System . Management . Automation ;
5- using System . Security ;
6- using System . Text ;
7- using System . Threading . Tasks ;
84using UiPath . Web . Client . Models ;
95
106namespace UiPath . PowerShell . Models
@@ -27,25 +23,32 @@ public class Asset
2723
2824 internal static Asset FromDto ( AssetDto dto )
2925 {
30- return new Asset
26+ var asset = new Asset
3127 {
3228 Id = dto . Id . Value ,
3329 Name = dto . Name ,
3430 ValueType = dto . ValueType ,
3531 ValueScope = dto . ValueScope ,
36- Value = dto . Value ,
37- RobotValues = dto . RobotValues ? . ToDictionary ( r => r . RobotId . Value , r=> r . Value ) ,
32+ Value = dto . ValueScope == AssetDtoValueScope . Global ? dto . Value : null ,
33+ RobotValues = dto . RobotValues ? . ToDictionary ( r => r . RobotId . Value , r => r . Value ) ,
3834 KeyValueList = dto . KeyValueList ? . ToDictionary ( kv => kv . Key , kv => kv . Value ) ,
3935 CanBeDeleted = dto . CanBeDeleted ,
40- WindowsCredential = ( dto . ValueType == AssetDtoValueType . WindowsCredential ) ?
41- new PSCredential (
42- dto . CredentialUsername ,
43- Cmdlets . AddAsset . MakeSecureString ( dto . CredentialPassword ) ) : null ,
44- Credential = ( dto . ValueType == AssetDtoValueType . Credential ) ?
45- new PSCredential (
36+ } ;
37+
38+ if ( dto . ValueScope == AssetDtoValueScope . Global && dto . ValueType == AssetDtoValueType . WindowsCredential )
39+ {
40+ asset . WindowsCredential = new PSCredential (
41+ dto . CredentialUsername ,
42+ Cmdlets . AddAsset . MakeSecureString ( dto . CredentialPassword ) ) ;
43+ }
44+ else if ( dto . ValueScope == AssetDtoValueScope . Global && dto . ValueType == AssetDtoValueType . Credential )
45+ {
46+ asset . Credential = new PSCredential (
4647 dto . CredentialUsername ,
47- Cmdlets . AddAsset . MakeSecureString ( dto . CredentialPassword ) ) : null
48+ Cmdlets . AddAsset . MakeSecureString ( dto . CredentialPassword ) ) ;
49+
4850 } ;
51+ return asset ;
4952 }
5053 }
5154}
0 commit comments