Beispiel #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;
            }
        }
Beispiel #2
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;
            }
        }