示例#1
0
        public override void RunCommand(object sender)
        {
            var engine            = (IAutomationEngineInstance)sender;
            var vAssetName        = v_AssetName.ConvertUserVariableToString(engine);
            var vAssetActionValue = v_AssetActionValue.ConvertUserVariableToString(engine);

            var client = AuthMethods.GetAuthToken();
            var asset  = AssetMethods.GetAsset(client, vAssetName, "Number");

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

            switch (v_AssetActionType)
            {
            case "Increment":
                AssetMethods.IncrementAsset(client, asset.Id);
                break;

            case "Decrement":
                AssetMethods.DecrementAsset(client, asset.Id);
                break;

            case "Add":
                AssetMethods.AddAsset(client, asset.Id, vAssetActionValue);
                break;

            case "Subtract":
                AssetMethods.SubtractAsset(client, asset.Id, vAssetActionValue);
                break;
            }
        }
示例#2
0
        public override void RunCommand(object sender)
        {
            var engine      = (IAutomationEngineInstance)sender;
            var vAssetName  = v_AssetName.ConvertUserVariableToString(engine);
            var vAppendText = v_AppendText.ConvertUserVariableToString(engine);

            var client = AuthMethods.GetAuthToken();
            var asset  = AssetMethods.GetAsset(client, vAssetName, "Text");

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

            AssetMethods.AppendAsset(client, asset.Id, vAppendText);
        }
        public override void RunCommand(object sender)
        {
            var engine               = (IAutomationEngineInstance)sender;
            var vAssetName           = v_AssetName.ConvertUserVariableToString(engine);
            var vOutputDirectoryPath = v_OutputDirectoryPath.ConvertUserVariableToString(engine);

            var client = AuthMethods.GetAuthToken();
            var asset  = AssetMethods.GetAsset(client, vAssetName, v_AssetType);

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

            dynamic assetValue;

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

            case "Number":
                assetValue = asset.NumberValue;
                break;

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

            case "File":
                var  fileID = asset.FileID;
                File file   = FileMethods.GetFile(client, fileID);
                AssetMethods.DownloadFileAsset(client, asset.Id, vOutputDirectoryPath, file.Name);
                assetValue = string.Empty;
                break;

            default:
                assetValue = string.Empty;
                break;
            }

            if (v_AssetType != "File")
            {
                ((object)assetValue).StoreInUserVariable(engine, v_OutputUserVariableName, nameof(v_OutputUserVariableName), this);
            }
        }
        public async override Task RunCommand(object sender)
        {
            var engine     = (IAutomationEngineInstance)sender;
            var vAssetName = (string)await v_AssetName.EvaluateCode(engine);

            var vOutputDirectoryPath = (string)await v_OutputDirectoryPath.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}'");
            }

            dynamic assetValue;

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

            case "Number":
                assetValue = asset.NumberValue;
                break;

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

            case "File":
                AssetMethods.DownloadFileAsset(userInfo, asset, vOutputDirectoryPath);
                assetValue = string.Empty;
                break;

            default:
                assetValue = string.Empty;
                break;
            }

            if (v_AssetType != "File")
            {
                ((object)assetValue).SetVariableValue(engine, v_OutputUserVariableName);
            }
        }
示例#5
0
        public async override Task RunCommand(object sender)
        {
            var engine     = (IAutomationEngineInstance)sender;
            var vAssetName = (string)await v_AssetName.EvaluateCode(engine);

            var vAppendText = (string)await v_AppendText.EvaluateCode(engine);

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

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

            AssetMethods.AppendAsset(userInfo, asset.Id, vAppendText);
        }
        public override void RunCommand(object sender)
        {
            var engine               = (AutomationEngineInstance)sender;
            var vAssetName           = v_AssetName.ConvertUserVariableToString(engine);
            var vOutputDirectoryPath = v_OutputDirectoryPath.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}'");
            }

            string assetValue = string.Empty;

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

            case "Number":
                assetValue = asset.NumberValue.ToString();
                break;

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

            case "File":
                var          binaryObjectID = asset.BinaryObjectID;
                BinaryObject binaryObject   = BinaryObjectMethods.GetBinaryObject(client, binaryObjectID);
                AssetMethods.DownloadFileAsset(client, asset.Id, vOutputDirectoryPath, binaryObject.Name);
                break;

            default:
                assetValue = string.Empty;
                break;
            }

            if (v_AssetType != "File")
            {
                assetValue.StoreInUserVariable(engine, v_OutputUserVariableName);
            }
        }
示例#7
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);
            }
        }
        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);
            }
        }
示例#9
0
        public async override Task RunCommand(object sender)
        {
            var engine     = (IAutomationEngineInstance)sender;
            var vAssetName = (string)await v_AssetName.EvaluateCode(engine);

            if (string.IsNullOrEmpty(v_AssetActionValue))
            {
                v_AssetActionValue = "0";
            }
            var vAssetActionValue = (int)await v_AssetActionValue.EvaluateCode(engine);

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

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

            switch (v_AssetActionType)
            {
            case "Increment":
                AssetMethods.IncrementAsset(userInfo, asset.Id);
                break;

            case "Decrement":
                AssetMethods.DecrementAsset(userInfo, asset.Id);
                break;

            case "Add":
                AssetMethods.AddAsset(userInfo, asset.Id, vAssetActionValue);
                break;

            case "Subtract":
                AssetMethods.SubtractAsset(userInfo, asset.Id, vAssetActionValue);
                break;
            }
        }