Example #1
0
        public bool Start(string[] args, IFlatFileLoader _flatFileLoader, ITimeManager _timeManager, IDataMonitorManager _sqldManager)
        {
            PerfTimer hptStartup = new PerfTimer();
            hptStartup.Start();

            flatFileLoader = _flatFileLoader;
            timeManager = _timeManager;
            dmManager = _sqldManager;

            this.CanStop = true;
            this.CanShutdown = true;

            log.Info("Starting BITS State Manager service...");

            log.Info("Establishing connection to NB service...");
            if (ExecutionEngine.InstanceOf().EstablishBrokerConnections() == false)
            {
                log.Error("Cannot connect to NB service.  Quitting...");
                return false;
            }

            log.Info("Creating Module Factory instance...");
            ModuleFactory mFactory = new ModuleFactory();

            log.Info("Starting to load Module type definitions...");
            LoadAdapters();
            //AutoLoadAdapters(AppDomain.CurrentDomain.BaseDirectory + "modules");

            log.Info("Looking for startup jobs to build...");
            ExecuteStartupJobs();

            hptStartup.Stop();
            log.InfoFormat("BITS State Manager service has started in {0} seconds.", hptStartup.Duration);
            return true;
        }
Example #2
0
        public static void Startup(string[] args)
        {

            if (args.Length > 0 && (args[0].ToLower() == "-console" || args[0].ToLower() == "-c"))
            {
                isConsole = true;
            }
            else if (args.Length > 0 && (args[0].ToLower() == "-test"))
            {
                isRegressionTest = true;
            }

            log.Info("---------------------------------------------------------------------------");
            log.Info("BITS Shell");
            log.Info("Started at [" + System.DateTime.Now.ToLongTimeString() + "]");
            log.Info("---------------------------------------------------------------------------");
            
            log.Info("Loading configuration...");
            try
            {
                ConfigUtils.GlobalConfig = (GlobalConfigDetails)ConfigurationManager.GetSection("BitsConfig");
                GetCentralConfig(ref ConfigUtils.GlobalConfig);
                GetNbConfig();

                log.Info("Initializing persistence layer...");
                Repository.SetFactory(new LocalRepositoryFactory());
                Repository.SetContext(new ContextUser());
            }
            catch (Exception ex)
            {
                log.Error(ex);
                log.ErrorFormat("Terminating...");
                return;
            }


            log.Info("Starting dependent service(s)...");
            fileManagerService = new FileManagerService();
            timeManagerService = new TimeManagerService();
            stateManagerService = new StateManagerService();
            datamonitorManager = DataMonitorManager.InstanceOf(ConfigUtils.GlobalConfig);

            if (isConsole)
            {
                IFlatFileLoader ffLoader = fileManagerService.Start(args, ConfigUtils.GlobalConfig);
                ITimeManager tManager = timeManagerService.Start(args, ConfigUtils.GlobalConfig);

                if (StateManagerService.Start(args, ffLoader, tManager, datamonitorManager))
                {
                    Console.WriteLine("Waiting for tasks, press enter to stop service...");
                    Console.ReadLine();
                    Console.WriteLine("Service stopping...");
                }

                try
                {
                    StopFileManagerService();
                    StopTimeManagerService();
                    StopStateManagerService();
                    StopDataMonitorService();
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }

                Console.WriteLine("Service stopped.");
            }
            else if (isRegressionTest)
            {
                //ScheduledJobsTest test = new ScheduledJobsTest();
                //test.RunAllScheduledJobs();
            }
            else
            {
                bitsShellService = new BitsShellService();
                ServiceBase.Run(bitsShellService);
            }

        }
Example #3
0
 public static void StartStateManagerService(IFlatFileLoader ffLoader, ITimeManager tManager, IDataMonitorManager sqldManager)
 {
     StateManagerService.Start(null, ffLoader, tManager, sqldManager);
 }
Example #4
0
        public virtual StateEnums.Status Initialize(IJob _job, IFlatFileLoader ffLoader, ITimeManager tManager, IDataMonitorManager dm)
        {
            job = _job;
            flatFileLoader = ffLoader;
            timeManager = tManager;
            dmManager = dm;

            return Initialize(job);
        }