1
- using System ;
2
- using System . Collections . Generic ;
1
+ using System . Collections . Generic ;
3
2
using System . Linq ;
4
3
using System . Management . Automation ;
5
- using System . Security ;
6
- using System . Text ;
7
- using System . Threading . Tasks ;
8
4
using UiPath . Web . Client . Models ;
9
5
10
6
namespace UiPath . PowerShell . Models
@@ -27,25 +23,32 @@ public class Asset
27
23
28
24
internal static Asset FromDto ( AssetDto dto )
29
25
{
30
- return new Asset
26
+ var asset = new Asset
31
27
{
32
28
Id = dto . Id . Value ,
33
29
Name = dto . Name ,
34
30
ValueType = dto . ValueType ,
35
31
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 ) ,
38
34
KeyValueList = dto . KeyValueList ? . ToDictionary ( kv => kv . Key , kv => kv . Value ) ,
39
35
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 (
46
47
dto . CredentialUsername ,
47
- Cmdlets . AddAsset . MakeSecureString ( dto . CredentialPassword ) ) : null
48
+ Cmdlets . AddAsset . MakeSecureString ( dto . CredentialPassword ) ) ;
49
+
48
50
} ;
51
+ return asset ;
49
52
}
50
53
}
51
54
}
0 commit comments