Esempio n. 1
0
        protected override void OnStart(string[] args)
        {
            // log
            ErrorLogger.Log(ErrorLogger.LogType.INBOUND_SERVICE_STARTING, DateTime.Now.ToString());

            // init thread dictionary
            this.socketDictionary = new Dictionary <int, Socket>();

            // get all configuration data
            List <Configuration> configs = ConfigurationDAO.GetApplications();

            // get return all incoming interface configurations
            List <Configuration> intefaceConfigs
                = ConfigurationUtility.GetIncomingInterfaces(configs);

            // start the interfaces by the database config
            intefaceConfigs.ForEach(delegate(Configuration appConfig)
            {
                // get the interfaces for this communication set
                List <Configuration> interfaces
                    = ConfigurationDAO.GetInterfaceConfigration(appConfig.communication);

                // for each of the inbound interface threads, start them
                interfaces.ForEach(delegate(Configuration intConfig)
                {
                    // get the outgoing database communication id
                    Configuration brokerDBConfig
                        = ConfigurationUtility.GetOutgoingDatabasesByApplicationId(configs, appConfig.application.id);

                    // pass the db communication to the class's communication list since we
                    intConfig.communications = new List <Communication>();
                    intConfig.communications.Add(brokerDBConfig.communication);

                    // add to queue
                    ThreadPool.QueueUserWorkItem(new WaitCallback(startInterface), intConfig);
                });
            });
        }