private IRowFilterCondition GetRowFilterCondition(string conditionSql, string conditionParamName, string conditionColumnName)
        {
            IRowFilterCondition rowFc = null;
            object value = GetValue();

            switch (selectedFieldType)
            {
            case MetaFieldType.Text:
            case MetaFieldType.TextUppercase:
            case MetaFieldType.PhoneNumber:
            case MetaFieldType.Multiline:
            case MetaFieldType.LegalValues:
            case MetaFieldType.CommentLegal:
            case MetaFieldType.Codes:
            case MetaFieldType.GUID:
                rowFc = new TextRowFilterCondition(conditionSql, conditionColumnName, conditionParamName, value);
                break;

            case MetaFieldType.Date:
            case MetaFieldType.DateTime:
            case MetaFieldType.Time:
                rowFc = new DateRowFilterCondition(conditionSql, conditionColumnName, conditionParamName, value);
                break;

            case MetaFieldType.Option:
            case MetaFieldType.Number:
                rowFc = new NumberRowFilterCondition(conditionSql, conditionColumnName, conditionParamName, value);
                break;

            case MetaFieldType.YesNo:
                rowFc = new YesNoRowFilterCondition(conditionSql, conditionColumnName, conditionParamName, value);
                break;

            case MetaFieldType.Checkbox:
                rowFc = new CheckboxRowFilterCondition(conditionSql, conditionColumnName, conditionParamName, value);
                break;

            default:
                throw new ApplicationException("Not a valid field type");
            }

            return(rowFc);
        }
Ejemplo n.º 2
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            Epi.ImportExport.Filters.ConditionJoinTypes op = Epi.ImportExport.Filters.ConditionJoinTypes.And;

            if (cmbLogicalOperator.SelectedIndex == 2)
            {
                op = Epi.ImportExport.Filters.ConditionJoinTypes.Or;
            }

            Filters = new RowFilters(this.DataHelper.Database, op);

            if (Click != null)
            {
                if (includeCasesOnly.IsChecked == true)
                {
                    IncludeCases         = true;
                    IncludeCaseExposures = true;
                    IncludeContacts      = false;
                }

                if (includeCasesContacts.IsChecked == true)
                {
                    IncludeCases         = true;
                    IncludeCaseExposures = true;
                    IncludeContacts      = true;
                }

                if (checkboxDeidentifyData.IsChecked == true)
                {
                    DeIdentifyData = true;
                }
                else
                {
                    DeIdentifyData = false;
                }

                switch (cmbRecordProcessingScope.SelectedIndex)
                {
                case 0:
                    RecordProcessingScope = Epi.RecordProcessingScope.Undeleted;
                    break;

                case 1:
                    RecordProcessingScope = Epi.RecordProcessingScope.Deleted;
                    break;

                case 2:
                    RecordProcessingScope = Epi.RecordProcessingScope.Both;
                    break;
                }

                // NOTE: Contact-only exports were removed at request of project coordinator...
                //if (includeContactsOnly.IsChecked == true)
                //{
                //    IncludeCases = false;
                //    IncludeCaseExposures = false;
                //    IncludeContacts = true;
                //}

                IDbDriver db = this.DataHelper.Database;
                // data package filters
                if (checkboxFilterData.IsChecked == true)
                {
                    string varName1 = cmbVariableName1.Text.Trim();
                    string value1   = tboxValue1.Text.Trim();

                    string varName2 = cmbVariableName2.Text.Trim();
                    string value2   = tboxValue2.Text.Trim();

                    #region Check to see if user's filtering options make sense

                    if (String.IsNullOrEmpty(varName1) && String.IsNullOrEmpty(value1))
                    {
                        MessageBox.Show("Neither a variable nor a value have been selected for the first condition. Please ensure both a variable and a value are present before proceeding.", "Missing filter information", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    if (!String.IsNullOrEmpty(varName1) && String.IsNullOrEmpty(value1))
                    {
                        MessageBox.Show("A variable has been selected for the first condition, but no value has been specified. Please specify a value and try again.", "No value specified", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    if (!String.IsNullOrEmpty(value1) && String.IsNullOrEmpty(varName1))
                    {
                        MessageBox.Show("A value has been selected for the first condition, but no variable has been specified. Please specify a variable on which to filter and try again.", "No variable specified", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    if (cmbLogicalOperator.SelectedIndex == 1 && String.IsNullOrEmpty(varName2) && String.IsNullOrEmpty(value2))
                    {
                        MessageBox.Show("Neither a variable nor a value have been selected for the second condition. Please ensure both a variable and a value are present before proceeding.", "Missing filter information", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    if (cmbLogicalOperator.SelectedIndex == 1 && !String.IsNullOrEmpty(varName2) && String.IsNullOrEmpty(value2))
                    {
                        MessageBox.Show("A variable has been selected for the second condition, but no value has been specified. Please specify a value and try again.", "No value specified", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    if (cmbLogicalOperator.SelectedIndex == 1 && !String.IsNullOrEmpty(value2) && String.IsNullOrEmpty(varName2))
                    {
                        MessageBox.Show("A value has been selected for the second condition, but no variable has been specified. Please specify a variable on which to filter and try again.", "No variable specified", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    #endregion

                    if (!String.IsNullOrEmpty(varName1) && !String.IsNullOrEmpty(value1))
                    {
                        if (cmbOperator1.SelectedIndex == 0)
                        {
                            TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName1 + "] = @" + varName1 + "", "" + varName1 + "", "@" + varName1 + "", value1);
                            tfc.Description = "" + varName1 + " equals " + value1;
                            Filters.Add(tfc);
                        }
                        else
                        {
                            value1 = "%" + value1 + "%";
                            TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName1 + "] LIKE @" + varName1 + "", "" + varName1 + "", "@" + varName1 + "", value1);
                            tfc.Description = "" + varName1 + " contains " + value1;
                            Filters.Add(tfc);
                        }
                    }

                    if (!String.IsNullOrEmpty(varName2) && !String.IsNullOrEmpty(value2))
                    {
                        if (cmbOperator2.SelectedIndex == 0)
                        {
                            TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName2 + "] = @" + varName2 + "", "" + varName2 + "", "@" + varName2 + "", value2);
                            tfc.Description = "" + varName2 + " equals " + value2;
                            Filters.Add(tfc);
                        }
                        else
                        {
                            value2 = "%" + value2 + "%";
                            TextRowFilterCondition tfc = new TextRowFilterCondition("[" + varName2 + "] LIKE @" + varName2 + "", "" + varName2 + "", "@" + varName2 + "", value2);
                            tfc.Description = "" + varName2 + " contains " + value2;
                            Filters.Add(tfc);
                        }
                    }
                }

                RoutedEventArgs args = new RoutedEventArgs(CaseExportOptions.OkClickEvent);
                Click(this, args);
            }
        }
Ejemplo n.º 3
0
        private void StartExportCommandExecute()
        {
            switch (RecordScope)
            {
            case "Deleted":
                RecordProcessingScope = RecordProcessingScope.Deleted;
                break;

            case "Both":
                RecordProcessingScope = RecordProcessingScope.Both;
                break;

            case "Active":
            default:
                RecordProcessingScope = RecordProcessingScope.Undeleted;
                break;
            }

            Epi.ImportExport.Filters.ConditionJoinTypes op = Epi.ImportExport.Filters.ConditionJoinTypes.And;

            if (FilterJoinType != null && FilterJoinType.Equals("or", StringComparison.OrdinalIgnoreCase))
            {
                op = Epi.ImportExport.Filters.ConditionJoinTypes.Or;
            }

            ContactTracing.ImportExport.SyncFileFilters filters = new ContactTracing.ImportExport.SyncFileFilters(Database, op);

            if (ApplyFilters == true)
            {
                #region Check to see if user's filtering options make sense

                //if (String.IsNullOrEmpty(varName1) && String.IsNullOrEmpty(value1))
                //{
                //    MessageBox.Show("Neither a variable nor a value have been selected for the first condition. Please ensure both a variable and a value are present before proceeding.", "Missing filter information", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                //if (!String.IsNullOrEmpty(varName1) && String.IsNullOrEmpty(value1))
                //{
                //    MessageBox.Show("A variable has been selected for the first condition, but no value has been specified. Please specify a value and try again.", "No value specified", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                //if (!String.IsNullOrEmpty(value1) && String.IsNullOrEmpty(varName1))
                //{
                //    MessageBox.Show("A value has been selected for the first condition, but no variable has been specified. Please specify a variable on which to filter and try again.", "No variable specified", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                //if (cmbLogicalOperator.SelectedIndex == 1 && String.IsNullOrEmpty(varName2) && String.IsNullOrEmpty(value2))
                //{
                //    MessageBox.Show("Neither a variable nor a value have been selected for the second condition. Please ensure both a variable and a value are present before proceeding.", "Missing filter information", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                //if (cmbLogicalOperator.SelectedIndex == 1 && !String.IsNullOrEmpty(varName2) && String.IsNullOrEmpty(value2))
                //{
                //    MessageBox.Show("A variable has been selected for the second condition, but no value has been specified. Please specify a value and try again.", "No value specified", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                //if (cmbLogicalOperator.SelectedIndex == 1 && !String.IsNullOrEmpty(value2) && String.IsNullOrEmpty(varName2))
                //{
                //    MessageBox.Show("A value has been selected for the second condition, but no variable has been specified. Please specify a variable on which to filter and try again.", "No variable specified", MessageBoxButton.OK, MessageBoxImage.Error);
                //    return;
                //}

                #endregion

                if (!String.IsNullOrEmpty(FilterField1) && !String.IsNullOrEmpty(FilterValue1))
                {
                    if (FilterOperator1.Equals("equals", StringComparison.OrdinalIgnoreCase))
                    {
                        TextRowFilterCondition tfc = new TextRowFilterCondition("[" + FilterField1 + "] = @" + FilterField1 + "", "" + FilterField1 + "", "@" + FilterField1 + "", FilterValue1);
                        tfc.Description = "" + FilterField1 + " equals " + FilterValue1;
                        filters.Add(tfc);
                    }
                    else
                    {
                        string tempFilterValue1    = "%" + FilterValue1 + "%";
                        TextRowFilterCondition tfc = new TextRowFilterCondition("[" + FilterField1 + "] LIKE @" + FilterField1 + "", "" + FilterField1 + "", "@" + FilterField1 + "", tempFilterValue1);
                        tfc.Description       = "" + FilterField1 + " contains " + tempFilterValue1;
                        tfc.ConditionOperator = ConditionOperators.Contains;
                        filters.Add(tfc);
                    }
                }

                if (!String.IsNullOrEmpty(FilterField2) && !String.IsNullOrEmpty(FilterValue2))
                {
                    if (FilterOperator2.Equals("equals", StringComparison.OrdinalIgnoreCase))
                    {
                        TextRowFilterCondition tfc = new TextRowFilterCondition("[" + FilterField2 + "] = @" + FilterField2 + "", "" + FilterField2 + "", "@" + FilterField2 + "", FilterValue2);
                        tfc.Description = "" + FilterField2 + " equals " + FilterValue2;
                        filters.Add(tfc);
                    }
                    else
                    {
                        string tempFilterValue2    = "%" + FilterValue2 + "%";
                        TextRowFilterCondition tfc = new TextRowFilterCondition("[" + FilterField2 + "] LIKE @" + FilterField2 + "", "" + FilterField2 + "", "@" + FilterField2 + "", tempFilterValue2);
                        tfc.Description       = "" + FilterField2 + " contains " + tempFilterValue2;
                        tfc.ConditionOperator = ConditionOperators.Contains;
                        filters.Add(tfc);
                    }
                }
            }

            CreateCaseSyncFileStart(filters);
        }