Exemplo n.º 1
0
        public void StartSources()
        {
            try
            {
                ConfigurationDatabase = LocalConfigurationDatabase.GetConfigurationDatabase();
            }
            catch (Exception exception)
            {
                Console.WriteLine("Failed to get configuration database. " + exception.Message);

                if (eventLog != null)
                {
                    eventLog.WriteEntry("Failed to get configuration database. " + exception.Message, EventLogEntryType.Error);
                }
            }

            try
            {
                if (ConfigurationDatabase != null)
                {
                    CollectionDatabaseConfiguration collectionDatabaseConfiguration = new CollectionDatabaseConfiguration(ConfigurationDatabase);
                    CollectionDatabase = collectionDatabaseConfiguration.GetCollectionDatabase();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Failed to get collection database. " + exception.Message);

                if (eventLog != null)
                {
                    eventLog.WriteEntry("Failed to get collection database. " + exception.Message, EventLogEntryType.Error);
                }
            }

            try
            {
                FileSources = GetFileSources();

                if (FileSources != null)
                {
                    foreach (FileSource fileSource in FileSources)
                    {
                        fileSource.AddCollectionDatabase(CollectionDatabase);
                        fileSource.AddConfigurationDatabase(ConfigurationDatabase);
                        fileSource.Start();
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Failed to get file source information from configuration database. " + exception.Message);

                if (eventLog != null)
                {
                    eventLog.WriteEntry("Failed to get file source information from configuration database. " + exception.Message, EventLogEntryType.Error);
                }
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ServiceHost serviceHost;
            Program     service = new Program();

            if (Environment.UserInteractive)
            {
                serviceHost = new ServiceHost(service);

                Database ConfigurationDatabase = null;
                try
                {
                    ConfigurationDatabase = LocalConfigurationDatabase.GetConfigurationDatabase();
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Failed to get configuration database. " + exception.Message);
                }

                if (ConfigurationDatabase != null)
                {
                    FileTypeTableInstallation.CreateFileTypeTable(ConfigurationDatabase);
                    ColumnTableInstallation.CreateColumnTable(ConfigurationDatabase);
                    FooterTableInstallation.CreateFooterTable(ConfigurationDatabase);
                    HeaderTableInstallation.CreateHeaderTable(ConfigurationDatabase);
                    SettingsTableInstallation.CreateSettingsTable(ConfigurationDatabase);
                    FileSourceTableInstallation.CreateFileSourceTable(ConfigurationDatabase);
                    Console.WriteLine("Installed tables!");
                }
                else
                {
                    Console.WriteLine("Failed to install tables.");
                }

                serviceHost.Open();
                service.OnStart(args);

                Console.ReadLine();
            }
            else
            {
                serviceHost = new ServiceHost(service);
                serviceHost.Open();
                Run(service);
            }
        }
Exemplo n.º 3
0
        public ProjectInstaller()
        {
            process             = new ServiceProcessInstaller();
            process.Account     = ServiceAccount.LocalSystem;
            service             = new ServiceInstaller();
            service.ServiceName = "ethosIQ-File-Reader-Service";
            Installers.Add(process);
            Installers.Add(service);

            try
            {
                ConfigurationDatabase = LocalConfigurationDatabase.GetConfigurationDatabase();
            }
            catch (Exception exception)
            {
                Console.WriteLine("Failed to get configuration database information. " + exception.Message);
            }

            if (ConfigurationDatabase != null)
            {
                FooterTableInstallation.CreateFooterTable(ConfigurationDatabase);
                Console.WriteLine("Created footer table.");

                SettingsTableInstallation.CreateSettingsTable(ConfigurationDatabase);
                Console.WriteLine("Created file settings table.");

                ColumnTableInstallation.CreateColumnTable(ConfigurationDatabase);
                Console.WriteLine("Created column table.");

                FileSourceTableInstallation.CreateFileSourceTable(ConfigurationDatabase);
                Console.WriteLine("Created file source table.");

                HeaderTableInstallation.CreateHeaderTable(ConfigurationDatabase);
                Console.WriteLine("Created header table.");

                FileTypeTableInstallation.CreateFileTypeTable(ConfigurationDatabase);
                Console.WriteLine("Created file type table.");

                CollectionDatabaseInstallation.CreateCollectionDatabaseTable(ConfigurationDatabase);
                Console.WriteLine("Created collection database table");
            }
        }
Exemplo n.º 4
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)
                    {
                    }
                }
            }
        }