コード例 #1
0
ファイル: TimedEventsThread.cs プロジェクト: orf53975/GameSrv
        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
ファイル: RunDoor.cs プロジェクト: orf53975/GameSrv
        private void RunDoorDOSBox(string command, string parameters)
        {
            if (Helpers.Debug)
            {
                _ClientThread.UpdateStatus("DEBUG: DOSBox launching " + command + " " + parameters);
            }

            string DOSBoxConf      = StringUtils.PathCombine("node" + _ClientThread.NodeInfo.Node.ToString(), "dosbox.conf");
            string ProgramFilesX86 = Environment.GetEnvironmentVariable("PROGRAMFILES(X86)") ?? Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            string DOSBoxExe       = StringUtils.PathCombine(ProgramFilesX86, @"DOSBox-0.73\dosbox.exe"); // TODOZ add configuration variable so this path is not hardcoded

            // Copy base dosbox.conf
            FileUtils.FileDelete(DOSBoxConf);
            FileUtils.FileCopy("dosbox.conf", DOSBoxConf);

            // If we're running a batch file, add a CALL to it
            if (command.ToUpper().Contains(".BAT"))
            {
                command = "call " + command;
            }

            string[] ExternalBat = new string[] { "mount c " + StringUtils.ExtractShortPathName(ProcessUtils.StartupPath), "C:", command + " " + parameters, "exit" };
            FileUtils.FileAppendAllText(DOSBoxConf, string.Join("\r\n", ExternalBat));

            // TODOZ Todd/maskreet does it this way -- maybe safer with commands passed this way, or at the very least with -securemode?

            /* dosbox.exe -c "mount d c:\games\!u_games\%4\%1" -c "mount e c:\doorway"
             *  -c "mount f c:\doorsrv\node%3" -c "e:" -c "bnu" -c "DOORWAY.EXE SYSF
             *  CFG\%1.cfg" -securemode -socket %2 -c "exit"
             */
            string Arguments = "-telnet -conf " + DOSBoxConf + " -socket " + _ClientThread.NodeInfo.Connection.GetSocket().Handle.ToInt32().ToString();

            if (Helpers.Debug)
            {
                _ClientThread.UpdateStatus("Executing " + DOSBoxExe + " " + Arguments);
            }

            // Start the process
            using (RMProcess P = new RMProcess()) {
                P.ProcessWaitEvent += _ClientThread.OnDoorWait;

                ProcessStartInfo PSI = new ProcessStartInfo(DOSBoxExe, Arguments)
                {
                    WindowStyle      = _ClientThread.NodeInfo.Door.WindowStyle,
                    WorkingDirectory = ProcessUtils.StartupPath,
                };
                P.StartAndWait(PSI);
            }
        }
コード例 #3
0
ファイル: RunDoor.cs プロジェクト: orf53975/GameSrv
        public void RunDoorNative(string command, string parameters)
        {
            if (Helpers.Debug)
            {
                _ClientThread.UpdateStatus("DEBUG: Natively launching " + command + " " + parameters);
            }
            using (RMProcess P = new RMProcess()) {
                P.ProcessWaitEvent += _ClientThread.OnDoorWait;

                ProcessStartInfo PSI = new ProcessStartInfo(command, parameters)
                {
                    WindowStyle      = _ClientThread.NodeInfo.Door.WindowStyle,
                    WorkingDirectory = ProcessUtils.StartupPath,
                };
                P.StartAndWait(PSI);
            }
        }
コード例 #4
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);
            }
        }