Пример #1
0
        protected override void Execute()
        {
            // Load the events into memory
            var EventNames = TimedEvent.GetEventNames();

            foreach (var EventName in EventNames)
            {
                _TimedEvents.Add(new TimedEvent(EventName));
            }

            while (!_Stop)
            {
                // Get the current day and time, which we'll compare to the list of events in memory
                string CurrentDay  = DateTime.Now.DayOfWeek.ToString();
                string CurrentTime = DateTime.Now.ToString("HH:mm");

                // Get matching events
                var EventsToRun = _TimedEvents.Where(x => x.Days.Contains(CurrentDay) && x.Time == CurrentTime);
                foreach (var EventToRun in EventsToRun)
                {
                    // Check if we need to go offline for this event
                    if (EventToRun.GoOffline)
                    {
                        RMLog.Info("Going offline to run event '" + EventToRun.Name + "'");
                        _ActiveOfflineEvents += 1;
                        // TODOX Raise event to take GameSrv offline
                    }
                    else
                    {
                        RMLog.Info("Running event '" + EventToRun.Name + "'");
                    }

                    // Execute the event
                    ProcessStartInfo PSI = new ProcessStartInfo(EventToRun.Command)
                    {
                        WindowStyle      = EventToRun.WindowStyle,
                        WorkingDirectory = ProcessUtils.StartupPath,
                    };
                    var P = RMProcess.Start(PSI);

                    // TODOX Need to get notification of the event completing so we can go back online
                }

                // Wait until the next minute rolls around to try again
                if (!_Stop && (_StopEvent != null))
                {
                    _StopEvent.WaitOne((61 - DateTime.Now.Second) * 1000);
                }
            }
        }
Пример #2
0
        private bool StartProcess()
        {
            // Start the process
            string           FileName  = StringUtils.PathCombine(ProcessUtils.StartupPath, "DOSXTRN.EXE");
            string           Arguments = StringUtils.ExtractShortPathName(EnvFile) + " NT " + _ClientThread.NodeInfo.Node.ToString() + " " + SBBSEXEC_MODE_FOSSIL.ToString() + " " + LoopsBeforeYield.ToString();
            ProcessStartInfo PSI       = new ProcessStartInfo(FileName, Arguments)
            {
                WindowStyle      = _ClientThread.NodeInfo.Door.WindowStyle,
                WorkingDirectory = ProcessUtils.StartupPath,
            };

            P = RMProcess.Start(PSI);

            if (P == null)
            {
                RMLog.Error("Error launching " + FileName + " " + Arguments);
                return(false);
            }
            else
            {
                return(true);
            }
        }