Example #1
0
 public VariableCommand(SsisTestSuite testSuite, object parent, VariableOperation operation, string name, string value)
     : this(testSuite, parent)
 {
     Properties[PropOperation] = new CommandProperty(PropOperation, operation.ToString());
     Properties[PropName]      = new CommandProperty(PropName, name);
     Properties[PropValue]     = new CommandProperty(PropValue, value);
 }
 public VariableOperationItem(string groupID, string key, VariableOperation opt, float value)
 {
     this.groupID = groupID;
     this.key     = key;
     this.type    = VariableType.Float;
     this.opt     = opt;
     this.vFloat  = value;
 }
 public VariableOperationItem(string groupID, string key, VariableOperation opt, bool value)
 {
     this.groupID = groupID;
     this.key     = key;
     this.type    = VariableType.Bool;
     this.opt     = opt;
     this.vBool   = value;
 }
 public VariableOperationItem(string groupID, string key, VariableOperation opt, string value)
 {
     this.groupID = groupID;
     this.key     = key;
     this.type    = VariableType.String;
     this.opt     = opt;
     this.vString = value;
 }
Example #5
0
        /// <summary>
        /// converts an operator to an operator string
        /// </summary>
        /// <param name="operation">operator to convert</param>
        /// <returns>string representation of operator</returns>
        public static string ToOperatorString(this VariableOperation operation)
        {
            if (operation < 0 || (int)operation >= operators.Length)
            {
                throw new ArgumentException($"Operator '{operation}' not supported");
            }

            return(operators[(int)operation]);
        }
Example #6
0
 /// <summary>
 /// creates a new <see cref="AssignStateNode"/>
 /// </summary>
 /// <param name="node">node of which to assign result</param>
 /// <param name="variableName">name of variable to assign result to</param>
 /// <param name="variableoperation">operation to use when assigning variable</param>
 /// <param name="compiler">compiler to use to compile variable operation</param>
 public AssignStateNode(IInstanceNode node, string variableName, VariableOperation variableoperation, IScriptCompiler compiler)
 {
     this.node    = node;
     VariableName = variableName;
     if (variableoperation != VariableOperation.Assign)
     {
         operation = compiler.CompileCode($"$lhs{variableoperation.ToOperatorString()}$rhs", ScriptLanguage.NCScript);
     }
 }
Example #7
0
        public async Task AssignWithOperationVariableNotExisting(VariableOperation operation, object expected)
        {
            Mock <IInstanceNode> instancenode = new Mock <IInstanceNode>();

            instancenode.Setup(s => s.Execute(It.IsAny <WorkflowInstanceState>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(11);
            Mock <IScriptCompiler> compiler = new Mock <IScriptCompiler>();

            compiler.Setup(s => s.CompileCode(It.IsAny <string>(), ScriptLanguage.NCScript)).Returns <string, ScriptLanguage>((code, language) => new ScriptParser().Parse(code));

            AssignStateNode node = new AssignStateNode(instancenode.Object, "result", operation, compiler.Object);

            Dictionary <string, object> variables = new Dictionary <string, object>();
            await node.Execute(new WorkflowInstanceState(new WorkflowIdentifier(), null, new StateVariableProvider(variables), s => null, null, null, false), CancellationToken.None);

            Assert.That(variables.ContainsKey("result"));
            Assert.AreEqual(expected, variables["result"]);
        }
        public void ParseChangeVariable(string t, Passage p)
        {
            // change:someVar:4
            try
            {
                VariableOperation oper = VariableOperation.UNKNOWN;
                int    colon1          = t.IndexOf(':');
                int    colon2          = t.IndexOf(':', colon1 + 1);
                string varName         = t.Substring(colon1 + 1, colon2 - colon1 - 1);
                string varValue        = t.Substring(colon2 + 1);
                // int colon3 = t.IndexOf(':', colon2 + 1);
                // string operation = t.Substring(colon2, colon3);
                // if (operation == "+")
                // {
                oper = VariableOperation.SUM;
                // }
                // else if (operation == "-")
                // {
                //     oper = VariableOperation.SUBTRACT;
                // }
                // else
                // {
                //     Debug.LogError($"DialogueManager: cant parse operation {operation}");
                // }
                // int colon4 = t.IndexOf(':', colon2 + 1);

                var s = new ChangeVariableSfStatement()
                {
                    variableName = varName,
                    operation    = oper,
                    operand      = varValue
                };
                p.effects.Add(s);
            }
            catch
            {
                Debug.LogError($"DialogueManager: Failed to parse tag {t}");
                throw;
            }
        }
Example #9
0
    public static int operation(this VariableOperation variableOperation, int a, int b)
    {
        switch (variableOperation)
        {
        case VariableOperation.set:
            return(b);

        case VariableOperation.add:
            return(a + b);

        case VariableOperation.sub:
            return(a - b);

        case VariableOperation.mul:
            return(a * b);

        case VariableOperation.div:
            return(a / b);

        case VariableOperation.mod:
            return(a % b);
        }
        return(0);
    }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VariableUsage" /> class.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="instruction">The instruction.</param>
 /// <param name="operation">The operation: read or write.</param>
 public VariableUsage(int index, Instruction instruction, VariableOperation operation)
 {
     Operation   = operation;
     Index       = index;
     Instruction = instruction;
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VariableUsage" /> class.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="instruction">The instruction.</param>
 /// <param name="operation">The operation: read or write.</param>
 public VariableUsage(int index, Instruction instruction, VariableOperation operation)
 {
     Operation = operation;
     Index = index;
     Instruction = instruction;
 }
Example #12
0
	public HamOperation()
	{
		this.VariableID = HamTimeline.InvalidID;
		this.Operator = VariableOperation.Set;
		this.Operand = null;
	}
Example #13
0
        /// <summary>
        /// Perform all operations selected in the treeview control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PerformOperationButton_Click(object sender, EventArgs e)
        {
            // Get list of operations from the OperationsTreeView
            List <string> operations = new List <string>();

            foreach (TreeNode node in OperationsTreeView.Nodes)
            {
                if (node.Checked)
                {
                    operations.Add(node.Text);
                }
                foreach (TreeNode childNode in node.Nodes)
                {
                    if (childNode.Checked)
                    {
                        operations.Add(childNode.Text);
                    }
                }
            }

            // If there isn't anything selected, then there isn't anything to do
            if (operations.Count == 0)
            {
                MessageBox.Show("Must choose at least one operation first!", "Copy Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                OperationsTreeView.Focus();
                return;
            }

            bool variableMapping = operations.Contains("Variable Mapping");

            if (!variableMapping || (variableMapping && operations.Count() > 1))
            {
                if (string.IsNullOrEmpty(SelectedProjectTextBox.Text.Trim()) || !File.Exists(SelectedProjectTextBox.Text.Trim()))
                {
                    MessageBox.Show("Select a master chart first!", "Copy Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    FindProjectButton.Focus();
                    return;
                }
            }
            if (string.IsNullOrEmpty(TargetProjectTextBox.Text.Trim()))
            {
                MessageBox.Show("Choose a Target Project first!", "Copy Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                FindTargetProjectButton.Focus();
                return;
            }

            UpdatedChartsTextBox.Clear();

            // Create and update -prj folders if needed and then backup -prj folders
            bool success = qlikViewOperation.CreatePRJFolders(UpdatedChartsTextBox, SingleRadioButton.Checked, RefreshPrjCheckBox.Checked, AutomationCheckBox.Checked, targetDocuments);

            if (!success)
            {
                MessageBox.Show("Open each QVW that you wish to update and click \"Save\" in order to populate the associated -prj folder. Then run this app again.", "Manual -prj update notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            backupOperation.BackupAll(UpdatedChartsTextBox, SingleRadioButton.Checked, targetDocuments);

            foreach (string operation in operations)
            {
                switch (operation)
                {
                case "ColorMap":
                    copyOperation = new CopyOperation("ColorMap", "<ColorMap>", "</ColorMap>", true);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Background Color":
                    copyOperation = new CopyOperation("Frame Background Color", "<BackgroundColor>", "</BackgroundColor>", true);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    copyOperation = new CopyOperation("Frame Background Color Transparency", "<BkgAlpha>", "</BkgAlpha>", true);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Background Image":
                    copyOperation = new CopyOperation("Frame Background Image", "<Bmp enctype=\"base64\">", "</Bmp>", true);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    copyOperation = new CopyOperation("Frame Background Image Transparency", "<BkgAlpha>", "</BkgAlpha>", true);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    copyOperation = new CopyOperation("Frame Background Image Coverage", "<FullBkgBmp>", "</FullBkgBmp>", true);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Active Background":
                    copyOperation = new CopyOperation("Active Background", "<ActiveBgColor>", "</ActiveBgColor>", false);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Active Foreground":
                    copyOperation = new CopyOperation("Active Foreground", "<ActiveFgColor>", "</ActiveFgColor>", false);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Inactive Background":
                    copyOperation = new CopyOperation("Inactive Background", "<BgColor>", "</BgColor>", false);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Inactive Foreground":
                    copyOperation = new CopyOperation("Inactive Foreground", "<FgColor>", "</FgColor>", false);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Font":
                    copyOperation = new CopyOperation("Font", "<Font>", "</Font>", false);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Caption Font":
                    copyOperation = new CopyOperation("Caption Font", "<CaptionFont>", "</CaptionFont>", false);
                    copyOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Wallpaper Image":
                    wallpaperOperation = new WallpaperOperation("<WallpaperPic enctype=\"base64\">", "</WallpaperPic>");
                    wallpaperOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                case "Variable Mapping":
                    bool ignoreSV = (IgnoreSystemVariablesCheckBox.Visible ? IgnoreSystemVariablesCheckBox.Checked : true);
                    tabControl1.SelectedTab = VariableMappingTabPage;
                    tabControl1.Refresh();
                    VariableMappingTabPage.Select();
                    variableOperation = new VariableOperation("  <VariableProperties>",
                                                              "  </VariableProperties>",
                                                              VariableMappingDataGridView,
                                                              ObjectTextBox,
                                                              ObjectCountTextBox,
                                                              ObjectProgressBar,
                                                              VariableTextBox,
                                                              VariableProgressBar,
                                                              ignoreSV
                                                              );
                    variableOperation.PerformOperation(UpdatedChartsTextBox, SingleRadioButton.Checked, SelectedProjectTextBox.Text, targetDocuments);
                    break;

                default:
                    break;
                }
            }
            UpdatedChartsTextBox.Text += string.Format("Refreshing project{0} after operation{0}...", (SingleRadioButton.Checked ? "" : "(s)"));
            UpdatedChartsTextBox.Focus();
            UpdatedChartsTextBox.SelectAll();
            UpdatedChartsTextBox.ScrollToCaret();
            UpdatedChartsTextBox.Refresh();

            if (AutomationCheckBox.Checked)
            {
                qlikViewOperation.RefreshQVW(UpdatedChartsTextBox, targetDocuments);
            }

            MessageBox.Show("Operations Complete!", "Copy Operations", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //IgnoreSystemVariablesCheckBox.Visible = false;
        }