Exemple #1
0
        private void LoadAllToolStripMenuItemClick(object sender, EventArgs e)
        {
            var collectionParameters = new CollectionParameters(entityAttributes, entityRelationships,
                                                                filterQuery, lookupMaping, mapper, mapping);

            LoadAllFiles(NotificationService, tbSchemaPath, tbExportConfig, tbImportConfig, workingstate, collectionParameters);
        }
Exemple #2
0
        private void ButtonSchemaFolderPathClick(object sender, EventArgs e)
        {
            using (var fileDialog = new SaveFileDialog
            {
                Filter = "XML Files|*.xml",
                OverwritePrompt = false
            })
            {
                var dialogResult         = fileDialog.ShowDialog();
                var controller           = new SchemaController();
                var collectionParameters = new CollectionParameters(entityAttributes, entityRelationships, null, null, null, null);

                controller.SchemaFolderPathAction(NotificationService, tbSchemaPath, workingstate, collectionParameters /*entityAttributes, entityRelationships*/, dialogResult, fileDialog, LoadSchemaFile);
            }
        }
        public void SchemaFolderPathActionWithDialogResultCancel()
        {
            using (var fileDialog = new System.Windows.Forms.SaveFileDialog())
            {
                using (var schemaPathTextBox = new System.Windows.Forms.TextBox())
                {
                    var dialogResult         = System.Windows.Forms.DialogResult.Cancel;
                    var collectionParameters = new CollectionParameters(inputEntityAttributes, inputEntityRelationships, null, null, null, null);

                    FluentActions.Invoking(() => systemUnderTest.SchemaFolderPathAction(NotificationServiceMock.Object, schemaPathTextBox, inputWorkingstate, collectionParameters, dialogResult, fileDialog, (x1, x2, x3, x4, x5) => { }))
                    .Should()
                    .NotThrow();

                    schemaPathTextBox.Text.Should().BeEmpty();
                }
            }
        }
        public void CanInstantiate()
        {
            Dictionary <string, HashSet <string> > inputEntityAttributes    = null;
            Dictionary <string, HashSet <string> > inputEntityRelationships = null;
            Dictionary <string, string>            inputFilterQuery         = null;
            Dictionary <string, Dictionary <string, List <string> > >             inputLookupMaping = null;
            Dictionary <string, Dictionary <Guid, Guid> >                         inputMapper       = null;
            Dictionary <string, List <Item <EntityReference, EntityReference> > > inputMapping      = null;

            var systemUndertest = new CollectionParameters(inputEntityAttributes, inputEntityRelationships, inputFilterQuery, inputLookupMaping, inputMapper, inputMapping);

            systemUndertest.EntityAttributes.Should().BeNull();
            systemUndertest.EntityRelationships.Should().BeNull();
            systemUndertest.FilterQuery.Should().BeNull();
            systemUndertest.LookupMaping.Should().BeNull();
            systemUndertest.Mapper.Should().BeNull();
            systemUndertest.Mapping.Should().BeNull();
        }
        public void SchemaFolderPathActionWithDialogResultOkAndNonExistingFile()
        {
            var filename = "TestData\\nonexistingfile.xml";

            using (var fileDialog = new System.Windows.Forms.SaveFileDialog())
            {
                fileDialog.FileName = filename;

                using (var schemaPathTextBox = new System.Windows.Forms.TextBox())
                {
                    var dialogResult         = System.Windows.Forms.DialogResult.OK;
                    var collectionParameters = new CollectionParameters(inputEntityAttributes, inputEntityRelationships, null, null, null, null);

                    FluentActions.Invoking(() => systemUnderTest.SchemaFolderPathAction(NotificationServiceMock.Object, schemaPathTextBox, inputWorkingstate, collectionParameters, dialogResult, fileDialog, (x1, x2, x3, x4, x5) => { }))
                    .Should()
                    .NotThrow();

                    schemaPathTextBox.Text.Should().Be(filename);
                }
            }
        }
Exemple #6
0
        public void LoadAllFiles(INotificationService feedbackManager, TextBox schemaPath, TextBox exportConfig, TextBox importConfig, bool inputWorkingstate, CollectionParameters collectionParameters)
        {
            LoadSchemaFile(schemaPath.Text, inputWorkingstate, feedbackManager, collectionParameters.EntityAttributes, collectionParameters.EntityRelationships);

            var controller = new ConfigurationController();

            controller.LoadExportConfigFile(feedbackManager, exportConfig, collectionParameters.FilterQuery, collectionParameters.LookupMaping);
            controller.LoadImportConfigFile(feedbackManager, importConfig, collectionParameters.Mapper, collectionParameters.Mapping);
        }
Exemple #7
0
        /// <summary>
        /// Method to find a list of employees using a search option and pagination parameters.
        /// </summary>
        /// <param name="search">text to compare against lastname and phone number</param>
        /// <param name="parameters">pagination and sorting parameters</param>
        /// <returns></returns>
        public override async Task <IEnumerable <Employee> > FindAsync(string search, CollectionParameters parameters)
        {
            string orderby = string.Empty;
            string top     = string.Empty;
            string offset  = string.Empty;

            string where = string.Empty;

            if (parameters.OrderBy != null && parameters.OrderBy.Length > 0 && typeof(Employee).GetProperties().Count(f => f.Name.Equals(parameters.OrderBy)) == 1)
            {
                orderby = "ORDER BY " + parameters.OrderBy + ((parameters.Ordering == AscDec.Asc) ? " ASC" : " DESC");
            }

            if (parameters.Limit != null && parameters.Limit > 0)
            {
                top = $"TOP({parameters.Limit})";
            }

            if (parameters.Offset != null && parameters.Offset > 0)
            {
                offset = $"OFFSET {parameters.Offset} ROWS";
            }

            if (search != null && search.Length > 0)
            {
                offset = $"WHERE LastName LIKE '%{search}%' OR Phone LIKE '%{search}%' ";
            }

            string sql = $"SELECT {top} * FROM {_tableName} {where} {orderby} {offset} ";

            return(await _connection.QueryAsync <Employee>(sql, transaction : _transaction));
        }
Exemple #8
0
        public void SchemaFolderPathAction(INotificationService notificationService, TextBox schemaPathTextBox, bool inputWorkingstate, CollectionParameters collectionParameters, DialogResult dialogResult, SaveFileDialog fileDialog,
                                           Action <string, bool, INotificationService, Dictionary <string, HashSet <string> >, Dictionary <string, HashSet <string> > > loadSchemaFile
                                           )
        {
            if (dialogResult == DialogResult.OK)
            {
                schemaPathTextBox.Text = fileDialog.FileName.ToString(CultureInfo.InvariantCulture);

                if (File.Exists(schemaPathTextBox.Text))
                {
                    loadSchemaFile(schemaPathTextBox.Text, inputWorkingstate, notificationService, collectionParameters.EntityAttributes, collectionParameters.EntityRelationships);
                }
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                schemaPathTextBox.Text = null;
            }
        }