Пример #1
0
        private void removeFileSourceButton_Click(object sender, EventArgs e)
        {
            string          fileSourceName;
            DataGridViewRow fileSourceRow;

            if (fileSourceGridView.Rows.Count > 0)
            {
                fileSourceRow = fileSourceGridView.CurrentRow;

                fileSourceName = fileSourceRow.Cells["columnName"].Value.ToString();

                try
                {
                    FileSourceDAO fileSourceDAO = new FileSourceDAO(ConfigurationDatabase);
                    fileSourceDAO.Delete(fileSourceName);

                    FileSources = fileSourceDAO.GetAllFileSources();

                    if (FileSources != null)
                    {
                        fileSourceGridView.Rows.Remove(fileSourceRow);
                        fileSourceGridView.Refresh();
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Failed to remove File Source. " + exception.Message, "File Source Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
0
        private List <FileSource> GetFileSources()
        {
            if (ConfigurationDatabase != null)
            {
                FileSourceDAO fileSourceDAO = new FileSourceDAO(ConfigurationDatabase);

                return(fileSourceDAO.GetAllFileSources());
            }

            return(null);
        }
Пример #3
0
        private void loadConfigurationWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (!EventLog.SourceExists("File Reader Tool"))
            {
                EventLog.CreateEventSource("File Reader Tool", "File Reader Service");
            }

            eventLog        = new EventLog();
            eventLog.Log    = "File Reader Service";
            eventLog.Source = "File Reader Tool";

            try
            {
                ConfigurationDatabase = LocalConfigurationDatabase.GetConfigurationDatabase();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Configuration Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (ConfigurationDatabase != null)
            {
                try
                {
                    CollectionDatabaseConfiguration collectionDatabaseConfiguration = new CollectionDatabaseConfiguration(ConfigurationDatabase);
                    CollectionDatabase = collectionDatabaseConfiguration.GetCollectionDatabase();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message, "Collection Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (CollectionDatabase != null)
                {
                    try
                    {
                        CollectionDatabase.CreateOpenConnection();
                        connectedLabel.Invoke(new Action(() => connectedLabel.Text = "Connected"));
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message, "Collection Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                if (CollectionDatabase != null)
                {
                    databaseTypeTextBox.Invoke(new Action(() => databaseTypeTextBox.Text = CollectionDatabase.DatabaseType.ToString()));
                    dataSourceTextBox.Invoke(new Action(() => dataSourceTextBox.Text     = CollectionDatabase.DataSource));
                    hostTextBox.Invoke(new Action(() => hostTextBox.Text         = CollectionDatabase.Host));
                    portTextBox.Invoke(new Action(() => portTextBox.Text         = CollectionDatabase.Port.ToString()));
                    usernameTextBox.Invoke(new Action(() => usernameTextBox.Text = CollectionDatabase.Username));
                    passwordTextBox.Invoke(new Action(() => passwordTextBox.Text = CollectionDatabase.Password));
                }

                try
                {
                    FileTypeDAO fileTypeDAO = new FileTypeDAO(ConfigurationDatabase);
                    FileTypes = fileTypeDAO.GetAllFileTypes();
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Failed to get File Type Configuration. " + exception.Message, "File Type Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (FileTypes != null)
                {
                    try
                    {
                        foreach (FileType fileType in FileTypes)
                        {
                            fileTypeGridView.Invoke(new Action(() => fileTypeGridView.Rows.Add(fileType.FileTypeID.ToString(), fileType.Name, fileType.Delimiter, fileType.DatabaseStoredProcedureName)));
                        }
                    }
                    catch (Exception exception)
                    {
                    }
                }

                try
                {
                    FileSourceDAO fileSourceDAO = new FileSourceDAO(ConfigurationDatabase);
                    FileSources = fileSourceDAO.GetAllFileSources();
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Failed to get File Source Configuration. " + exception.Message, "File Source Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (FileSources != null)
                {
                    try
                    {
                        foreach (FileSource fileSource in FileSources)
                        {
                            fileSourceGridView.Invoke(new Action(() => fileSourceGridView.Rows.Add(fileSource.FileTypeID.ToString(), fileSource.Name.ToString(), fileSource.Directory.ToString())));
                        }
                    }
                    catch (Exception exception)
                    {
                    }
                }
            }
        }