예제 #1
0
        private void btnAddExpression_Click(object sender, RoutedEventArgs e)
        {
            //get the actual field name from the map here
            string fieldName = "";

            Model.Expression.fieldType ft = Model.Expression.fieldType.Unknown;

            if (cboFieldNames.SelectedValue.ToString() == _FieldNameAliasMap[cboFieldNames.SelectedIndex].value[0])
            {
                fieldName = _FieldNameAliasMap[cboFieldNames.SelectedIndex].key;
                ft        = _FieldNameAliasMap[cboFieldNames.SelectedIndex].FieldType;
            }
            else
            {
                for (int i = 0; i < cboFieldNames.Items.Count; i++)
                {
                    if (_FieldNameAliasMap[i].value[0] == cboFieldNames.SelectedValue.ToString())
                    {
                        fieldName = _FieldNameAliasMap[i].key;
                        ft        = _FieldNameAliasMap[i].FieldType;
                    }
                }
            }

            string op    = cboOperators.SelectedValue as string;
            string value = txtSimpleExpression.Text;

            bool validValue = validateValue(ft, value);

            if (validValue)
            {
                Model.Expression exp = new Model.Expression(fieldName, op, value);

                foreach (StringItems2 item in FieldNameAliasMap)
                {
                    if (item.key == fieldName)
                    {
                        exp.FieldType = item.FieldType;
                        break;
                    }
                }

                if (expressions == null)
                {
                    expressions = new ObservableCollection <Model.Expression>();
                    lvExpressions.ItemsSource = expressions;
                    //TODO...may want to clean this up between when the diag is opened and closed
                    expressions.CollectionChanged += expressions_CollectionChanged;
                }

                expressions.Add(exp);

                if (lvExpressions.Visibility == System.Windows.Visibility.Hidden)
                {
                    lvExpressions.Visibility = System.Windows.Visibility.Visible;
                }
            }
        }
        public void Calculate()
        {
            Model.Expression exp = new Model.Expression(inputString);
            //exp.Tokenize();
            //exp.Validate();
            string result = exp.Calculate();

            OutputString = result;
        }
예제 #3
0
        private void btnAddAdvancedExpression_Click(object sender, RoutedEventArgs e)
        {
            Model.Expression exp = new Model.Expression(txtAdvancedExpression.Text);

            if (expressions == null)
            {
                expressions = new ObservableCollection <Model.Expression>();
                lvExpressions.ItemsSource      = expressions;
                expressions.CollectionChanged += expressions_CollectionChanged;
            }

            expressions.Add(exp);

            lvExpressions.Visibility = System.Windows.Visibility.Visible;
        }
예제 #4
0
        private async void finalValidation(Query q, Model.Expression e)
        {
            try
            {
                var qr = await dataSource.ExecuteQueryAsync(q);

                if (qr.Error != null)
                {
                    hasErrors = true;
                    expressions.Remove(e);

                    if (expressions.Count == 0)
                    {
                        lvExpressions.Visibility = System.Windows.Visibility.Hidden;
                    }
                }

                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }