Exemplo n.º 1
0
        private void StartNewMission(string logFilePath)
        {
            //Check if MissionEnd is sent
            if (missionHistory != null && missionHistory.Count > 0)
            {
                var existing = missionHistory.FirstOrDefault(data => data is MissionLogEventMissionEnd);
                if (existing == null)
                {
                    var endMission = new MissionLogEventMissionEnd(new MissionLogEventHeader(String.Format("T:{0} AType:7", lastTick), lastEventTime));
                    AddHistory(endMission);
                    actionManager.ProcessAction(endMission);
                }
            }
            Log.WriteInfo("New mission started {0}", logFilePath);
            missionDateTimePrefix = Re.GetSubString(logFilePath, @"missionReport\((.*)?\)\[0\]\.txt");

            if (String.IsNullOrWhiteSpace(missionDateTimePrefix))
            {
                return;
            }

            server.ResetMission();

            server.CurrentMissionId = GuidUtility.Create(GuidUtility.IsoOidNamespace, String.Concat(server.ServerId, "_", missionDateTimePrefix)).ToString();
            MissionStartDateTime    = Util.ParseDate(missionDateTimePrefix).ToUniversalTime();
        }
Exemplo n.º 2
0
 public Server(string name, bool isConfigSet, bool isRconConnected)
 {
     Name            = name;
     ServerId        = GuidUtility.Create(GuidUtility.IsoOidNamespace, name);
     IsConfigSet     = isConfigSet;
     IsRconConnected = isRconConnected;
     Initialize();
 }
Exemplo n.º 3
0
        public GameObject(int id, string name)
        {
            Id             = id;
            Name           = name;
            Classification = GameObjectClass.Other.ToString("g");
            Purpose        = String.Empty;
            ObjectId       = GuidUtility.Create(GuidUtility.IsoOidNamespace, Name);
            GameObjectItem objInfo;

            if (GameInfo.ObjectsClassification.TryGetValue(name, out objInfo))
            {
                Classification = objInfo.Classification.ToString("g");
                Purpose        = objInfo.Purpose;
            }
            HitsSources = new List <HitsSource>();
        }
Exemplo n.º 4
0
        public GameObject(int id, string name)
        {
            this.Id             = id;
            this.Name           = name;
            this.Classification = GameObjectClass.Other.ToString("g");
            this.Purpose        = string.Empty;
            this.ObjectId       = GuidUtility.Create(GuidUtility.IsoOidNamespace, this.Name);

            if (GameInfo.ObjectsClassification.TryGetValue(name, out var objInfo))
            {
                this.Classification = objInfo.Classification.ToString("g");
                this.Purpose        = objInfo.Purpose;
            }

            this.HitsSources = new List <HitsSource>();
        }
Exemplo n.º 5
0
        private void AddServer(Server server)
        {
            var existingDServer = Servers.FirstOrDefault(s => s.Rcon.Config.GameRootFolder.Equals(server.Rcon.Config.GameRootFolder));

            if (existingDServer != null)
            {
                var process = Process.GetProcessById((int)existingDServer.Process.Id);
                //Previous DServer process didn't exit correctly
                if (process != null)
                {
                    process.Kill();
                    RemoveServer(existingDServer.Process.Id);
                    actionManager.RunServerStopScript(server);
                }
            }
            UI.Dispatch(() =>
            {
                lock (lockDservers)
                {
                    Servers.Add(server);
                    actionManager.RunServerStartScripts(server);
                }
            });
            Task.Factory.StartNew((obj) => {
                var srv = (obj as Server);
                if (srv == null)
                {
                    return;
                }

                srv.IsConfigSet = srv.Rcon.Config.IsConfigReady;
                (obj as Server).Login();
            }, server, TaskCreationOptions.LongRunning).ContinueWith((task, obj) =>
            {
                var srv = (obj as Server);
                if (srv == null)
                {
                    return;
                }

                srv.ServerId = GuidUtility.Create(GuidUtility.IsoOidNamespace, srv.Name);
                Log.WriteInfo("Start server monitor for server {0}", srv.Name);
                srv.MissionLogService.Start();
                srv.IsRconConnected = true;
            }, server);
        }
Exemplo n.º 6
0
        public static object GetData(string text, DateTime missionStartTime, int eventNumber, Server server)
        {
            var header = new MissionLogEventHeader(text, missionStartTime);

            header.Server = server;
            if (header.Type != EventType.Unknown)
            {
                header.EventID = GuidUtility.Create(GuidUtility.IsoOidNamespace, String.Concat(server.ServerId, "_", missionStartTime, "_", eventNumber));

                Func <MissionLogEventHeader, object> handler;
                if (dataFactory.TryGetValue(header.Type, out handler))
                {
                    return(handler(header));
                }
            }
            return(null);
        }
Exemplo n.º 7
0
        private void AddServer(Server server)
        {
            var existingDServer = this.Servers.FirstOrDefault(s => s.Rcon.Il2ServerConfig.GameRootFolder == server.Rcon.Il2ServerConfig.GameRootFolder);

            if (existingDServer != null)
            {
                try {
                    var process = Process.GetProcessById((int)existingDServer.Process.Id);
                    //Previous DServer process didn't exit correctly
                    if (process != null)
                    {
                        process.Kill();
                        this.RemoveServer(existingDServer.Process.Id);
                        this.actionManager.RunServerStopScript(server);
                    }
                } catch (Exception ex) {
                    // -- ignore the error
                }
            }

            UI.Dispatch(() => {
                lock (this.lockDservers) {
                    this.Servers.Add(server);
                    this.actionManager.RunServerStartScripts(server);
                }
            });

            // -- set appropriate attributes: (taken out of the async block)

            server.ServerId = GuidUtility.Create(GuidUtility.IsoOidNamespace, server.Name);

            var appConfig = Settings.Default.Config;

            if (appConfig.IsMissionLogMonitorEnabled)
            {
                Log.WriteInfo("Starting MissionLogService for the server {0}", server.Name);
                server.MissionLogService.Start();
            }
            else
            {
                Log.WriteInfo("MissionLogService for the server {0} is NOT started! MissionLogMonitor is DISABLED in the application Settings.", server.Name);
            }

            if (appConfig.IsRConEnabled && this.IsRunning)
            {
                server.Rcon.Start();
            }


            /*
             * Task.Factory.StartNew((obj) => {
             *      if (!(obj is Server srv)) {
             *              return;
             *      }
             *
             *      srv.IsConfigSet = srv.Rcon.Il2ServerConfig.IsConfigReady;
             *      srv.AccountLogin();
             *      srv.IsRconConnected = true;
             * },  server, TaskCreationOptions.LongRunning);
             */
        }