コード例 #1
0
        public async override Task RunCommand(object sender)
        {
            var engine     = (IAutomationEngineInstance)sender;
            var vAssetName = (string)await v_AssetName.EvaluateCode(engine);

            var vAssetFilePath = (string)await v_AssetFilePath.EvaluateCode(engine);

            var vAssetValue = (string)await v_AssetValue.EvaluateCode(engine);

            var userInfo = ServerSessionVariableMethods.GetUserInfo(engine);
            var asset    = AssetMethods.GetAsset(userInfo, vAssetName, v_AssetType);

            if (asset == null)
            {
                throw new DataException($"No Asset was found for '{vAssetName}' with type '{v_AssetType}'");
            }

            switch (v_AssetType)
            {
            case "Text":
                asset.TextValue = vAssetValue;
                break;

            case "Number":
                asset.NumberValue = double.Parse(vAssetValue);
                break;

            case "Json":
                asset.JsonValue = vAssetValue;
                break;

            case "File":
                AssetMethods.UpdateFileAsset(userInfo, asset, vAssetFilePath);
                break;
            }

            if (v_AssetType != "File")
            {
                AssetMethods.PutAsset(userInfo, asset);
            }
        }
コード例 #2
0
        public override void RunCommand(object sender)
        {
            var engine         = (AutomationEngineInstance)sender;
            var vAssetName     = v_AssetName.ConvertUserVariableToString(engine);
            var vAssetFilePath = v_AssetFilePath.ConvertUserVariableToString(engine);
            var vAssetValue    = v_AssetValue.ConvertUserVariableToString(engine);

            var client = AuthMethods.GetAuthToken();
            var asset  = AssetMethods.GetAsset(client, $"name eq '{vAssetName}' and type eq '{v_AssetType}'");

            if (asset == null)
            {
                throw new Exception($"No Asset was found for '{vAssetName}' with type '{v_AssetType}'");
            }

            switch (v_AssetType)
            {
            case "Text":
                asset.TextValue = vAssetValue;
                break;

            case "Number":
                asset.NumberValue = double.Parse(vAssetValue);
                break;

            case "JSON":
                asset.JsonValue = vAssetValue;
                break;

            case "File":
                AssetMethods.UpdateFileAsset(client, asset, vAssetFilePath);
                break;
            }

            if (v_AssetType != "File")
            {
                AssetMethods.PutAsset(client, asset);
            }
        }