Ejemplo n.º 1
0
        /*  saveCoreConfig()
         *
         * Saves core config (serializes Server Config Data) to XML File
         */
        public void saveCoreConfig()
        {
            // Initialize Config List
            var xmlNodeMaster = new List <KeyValuePairXMLConfigs <String, List <KeyValuePairXMLParameters <String, String> > > >();

            XmlSerializer serializer = new XmlSerializer(typeof(List <KeyValuePairXMLConfigs <String, List <KeyValuePairXMLParameters <String, String> > > >));

            // Loop each Server Config Item
            foreach (KeyValuePair <String, skbtServerConfig> ConfigItem in DictServerConfig)
            {
                skbtServerConfig ServerConfig = ConfigItem.Value;

                // XML Tags from Meta
                String Identifier = ConfigItem.Key;

                // Build XML Node
                var xmlNode = new List <KeyValuePairXMLParameters <String, String> >()
                {
                    new KeyValuePairXMLParameters <String, String>("configpath", this.DictServerMeta[Identifier].PathToConfig),
                    new KeyValuePairXMLParameters <String, String>("exepath", this.DictServerMeta[Identifier].PathToEXE),
                    new KeyValuePairXMLParameters <String, String>("textname", this.DictServerMeta[Identifier].textualName),
                    new KeyValuePairXMLParameters <String, String>("installed", (this.DictServerMeta[Identifier].isInstalled == true) ? "true" : "false")
                };

                // Add to Master Node for Server Config
                xmlNodeMaster.Add(new KeyValuePairXMLConfigs <String, List <KeyValuePairXMLParameters <String, String> > >(Identifier, xmlNode));
            }

            // Write Config List
            TextWriter WriteFileStream = new StreamWriter(this.skbtXMLConfigPath);

            serializer.Serialize(WriteFileStream, xmlNodeMaster);
            WriteFileStream.Close();
        }
Ejemplo n.º 2
0
        public bool IsKeepaliveActive(skbtServerConfig SrvConfig)
        {
            // Get Work Directory
            string heartbeatTxtPath = Path.Combine(SrvConfig.objServerProc.Path, @"batch_lib\wrkdir\heartbeat.txt");

            if (File.Exists(heartbeatTxtPath))
            {
                // Read heartbeat
                using (StreamReader sr = File.OpenText(heartbeatTxtPath))
                {
                    // Get First Line
                    string stamp = sr.ReadLine();

                    // Convert to Int32
                    Int32 stampBeat = Convert.ToInt32(stamp);

                    // Get Current Time
                    Int32 stampNow = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

                    // Compare
                    if ((stampNow - stampBeat) <= 8)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
 public skbtServerConfig(skbtServerConfig origin)
 {
     this.skbtDebugLevel    = origin.skbtDebugLevel;
     this.AutoTimeoutLength = origin.AutoTimeoutLength;
     this.BindToIP          = origin.BindToIP;
     this.CleanWER          = origin.CleanWER;
     this.AutoRestartDelay  = origin.AutoRestartDelay;
     this.IP = origin.IP;
     this.SpecificProcCheck   = origin.SpecificProcCheck;
     this.ManualTimeoutLength = origin.ManualTimeoutLength;
     this.objASMProc          = new skbtProcessConfigASM(
         origin.objASMProc.EXEFile,
         origin.objASMProc.Path,
         origin.objASMProc.Keepalive,
         origin.objASMProc.Priority,
         origin.objASMProc.Affinity,
         origin.objASMProc.LogFileName,
         origin.objASMProc.LogInterval
         );
     this.objBECProc = new skbtProcessConfigBEC(
         origin.objBECProc.EXEFile,
         origin.objBECProc.Path,
         origin.objBECProc.Keepalive,
         origin.objBECProc.Priority,
         origin.objBECProc.Affinity,
         origin.objBECProc.BEPath,
         origin.objBECProc.useDSC
         );
     this.objDatabaseProc = new skbtProcessConfigDatabase(
         origin.objDatabaseProc.EXEFile,
         origin.objDatabaseProc.Path,
         origin.objDatabaseProc.Keepalive,
         origin.objDatabaseProc.Priority,
         origin.objDatabaseProc.Affinity,
         origin.objDatabaseProc.UseZipBackups,
         origin.objDatabaseProc.DatabaseBackupInterval,
         origin.objDatabaseProc.BackupFolder,
         origin.objDatabaseProc.DatabaseDumpFileName,
         origin.objDatabaseProc.DatabaseDumpFilePath
         );
     this.objHeadlessClientProc = new skbtProcessConfigHC(
         origin.objHeadlessClientProc.EXEFile,
         origin.objHeadlessClientProc.Path,
         origin.objHeadlessClientProc.Keepalive,
         origin.objHeadlessClientProc.Priority,
         origin.objHeadlessClientProc.Affinity,
         origin.objHeadlessClientProc.LaunchParams
         );
     this.objServerProc = new skbtProcessConfigServer(
         origin.objServerProc.EXEFile,
         origin.objServerProc.Path,
         origin.objServerProc.Keepalive,
         origin.objServerProc.Priority,
         origin.objServerProc.Affinity,
         origin.objServerProc.Port,
         origin.objServerProc.ConfigPathBasic,
         origin.objServerProc.ConfigPathServer,
         origin.objServerProc.ProfileName,
         origin.objServerProc.ProfilePath,
         origin.objServerProc.CommandLine,
         origin.objServerProc.ModLine,
         origin.objServerProc.LogFilePath,
         origin.objServerProc.LogFileBackupPath,
         origin.objServerProc.UseZipLogs
         );
     this.objTeamspeakProc = new skbtProcessConfigTeamspeak(
         origin.objTeamspeakProc.EXEFile,
         origin.objTeamspeakProc.Path,
         origin.objTeamspeakProc.Keepalive,
         origin.objTeamspeakProc.Priority,
         origin.objTeamspeakProc.Affinity,
         origin.objTeamspeakProc.PortNumber
         );
     this.objCustomProc = new Dictionary <short, skbtProcessConfigCustom>();
     if (origin.objCustomProc != null)
     {
         foreach (KeyValuePair <short, skbtProcessConfigCustom> cc in origin.objCustomProc)
         {
             this.objCustomProc.Add(cc.Key, new skbtProcessConfigCustom(
                                        cc.Value.EXEFile,
                                        cc.Value.Path,
                                        cc.Value.Keepalive,
                                        cc.Value.Priority,
                                        cc.Value.Affinity,
                                        cc.Value.ID,
                                        cc.Value.Name,
                                        cc.Value.LaunchParams
                                        ));
         }
     }
     this.Port = origin.Port;
     this.ServerStartTimeout = origin.ServerStartTimeout;
     this.skbtConfigPath     = origin.skbtConfigPath;
 }
Ejemplo n.º 4
0
 public void setServerConfig(String Identifier, skbtServerConfig c)
 {
     this.DictServerConfig[Identifier] = c;
 }
Ejemplo n.º 5
0
 /*  addServerPath(String Identifier, skbtServerConfig ServerConfigObject)
  *
  * Adds a new path to be controlled/configured
  *
  * [Identifier]     Unique ID of the server/Arma config
  * [Path]           Path to Arma Server directory
  */
 public void addServerConfig(String n, skbtServerConfig c)
 {
     this.DictServerConfig.Add(n, c);
 }