public void AddParameter(String ParameterName)
        {
            var index = Parameters.Count;

            if (EmptyParameter)
            {
                Parameters.RemoveAt(0);
            }

            EmptyParameter = false;
            var param = new ParametersViewModel()
            {
                Parameter = ArgumentToModelItem(new InArgument <string>(ParameterName), Context),
                ValueData = ArgumentToModelItem(new InArgument <string>(""), Context),
            };

            Parameters.Add(param);
            UpdateParameterIndex(index);
        }
        private void InitializeParameters()
        {
            var ParamElem      = ModelItem.Properties[ParametersProperty];
            var ParametersREST = ParamElem?.Value?.GetCurrentValue() as List <ParametersArgument>;

            if (ParametersREST == null)
            {
                return;
            }

            foreach (var itemREST in ParametersREST)
            {
                var param = new ParametersViewModel()
                {
                    Parameter = ArgumentToModelItem(itemREST.Parameter, Context),
                    ValueData = ArgumentToModelItem(itemREST.ValueData, Context),
                    isEnabled = itemREST.isEnabled,
                    visi      = itemREST.visi,
                };
                Parameters.Add(param);
            }
        }
        private async void Get_rules_Click(object sender, RoutedEventArgs e)
        {
            btnMandatory.Content    = "Wait for data...";
            btnMandatory.IsEnabled  = false;
            btnAddParam.IsEnabled   = false;
            btnGetExample.IsEnabled = false;
            btnRunCMD.IsEnabled     = false;

            Boolean valid = false;
            var     task  = await(new CmdRestAPI(AuthToken, ServiceURL, cmdTypeMandatory, ServiceName)).ExecuteAsync();

            if (task.ValidConnection)
            {
                valid = true;
            }
            else
            {
                if (!Salesforce_Marketing_Cloud_Scope.Design_VALIDCONN)
                {
                    Init_Connection();
                    var task2 = await(new CmdRestAPI(dictionaryForUrl)).ExecuteAsync();

                    if (task2.ValidConnection)
                    {
                        AuthToken  = task2.RespAuthToken;
                        ServiceURL = task2.RespServiceURL;
                        Salesforce_Marketing_Cloud_Scope.Design_AUTH      = AuthToken;
                        Salesforce_Marketing_Cloud_Scope.Design_SERVICES  = ServiceURL;
                        Salesforce_Marketing_Cloud_Scope.Design_SOAP      = task2.RespSoapClient;
                        Salesforce_Marketing_Cloud_Scope.Design_VALIDCONN = true;
                    }
                    System.Threading.Thread.Sleep(500);
                    task = await(new CmdRestAPI(AuthToken, ServiceURL, cmdTypeMandatory, ServiceName)).ExecuteAsync();
                    if (task.ValidConnection)
                    {
                        valid = true;
                    }
                }
                else
                {
                    MessageBox.Show("Error on reading the parameters.");
                }
            }

            if ((valid) && (task.DataTableResp.Rows.Count > 0))
            {
                Parameters.Clear();
                foreach (DataRow row in task.DataTableResp.Rows)
                {
                    var param = new ParametersViewModel()
                    {
                        Parameter = ArgumentToModelItem(new InArgument <string> {
                            Expression = new Literal <string>(row[0].ToString())
                        }, Context),
                        ValueData = ArgumentToModelItem(Convert.ToInt32(row[1].ToString()) == 0 ? new InArgument <string> {
                        } : new InArgument <string> {
                            Expression = new Literal <string>("")
                        }, Context),
                        isEnabled = (Convert.ToInt32(row[1].ToString()) == 0?false:true),
                        visi      = (Convert.ToInt32(row[1].ToString()) == 0 ? Visibility.Visible : Visibility.Collapsed),
                    };
                    Parameters.Add(param);
                }
                UpdateParameterIndex(0);
                SaveParameters();
                EmptyParameter = false;
            }

            btnMandatory.Content    = "Get mandatory parameters";
            btnMandatory.IsEnabled  = true;
            btnAddParam.IsEnabled   = true;
            btnGetExample.IsEnabled = true;
            btnRunCMD.IsEnabled     = true;
        }