public void SaveConfig(string configFile) { if (this.config != null) { OPSConfig.SaveConfig(this.config, configFile); } }
public static void SaveConfig(OPSConfig conf, string configFile) { FileStream fos = File.OpenWrite(configFile); BinaryWriter bw = new BinaryWriter(fos); XMLArchiverOut archiverOut = new XMLArchiverOut(bw, false); bw.Write(Encoding.ASCII.GetBytes("<root xmlns=ops>\n")); archiverOut.Inout("ops_config", conf); bw.Write(Encoding.ASCII.GetBytes("</root>")); fos.Close(); }
public static void SaveConfig(OPSConfig conf, string configFile) { FileStream fos = File.OpenWrite(configFile); BinaryWriter bw = new BinaryWriter(fos); XMLArchiverOut archiverOut = new XMLArchiverOut(bw, false); bw.Write(Encoding.ASCII.GetBytes("<root xmlns=ops>\n")); archiverOut.Inout("ops_config", conf); bw.Write(Encoding.ASCII.GetBytes("</root>")); fos.Close(); }
public static bool Add(string filename, string domainID = "") { if (domainID != "") { // Check if domain already exist if (DomainExist(domainID)) { Logger.ExceptionLogger.LogMessage("OPSConfigRepository::Add(), domain already exist"); return(false); } } OPSConfig cfg = null; // Check if file already read if (files.ContainsKey(filename)) { cfg = files[filename]; } else { // Need to read file cfg = OPSConfig.GetConfig(filename); if (cfg == null) { return(false); } files[filename] = cfg; } // Get all domains read from file List <Domain> domains = cfg.getDomains(); bool retVal = false; // Add the choosen one(s) to our list if not already there for (int i = 0; i < domains.Count; i++) { if ((domainID == "") || (domains[i].GetDomainID() == domainID)) { if (DomainExist(domains[i].GetDomainID())) { Logger.ExceptionLogger.LogMessage("OPSConfigRepository::Add(), domain already exist"); } else { // Add unique domains to our list config.Add(domains[i]); retVal = true; } } } return(retVal); }
public static OPSConfig GetConfig(string configFile) { FileStream fis = File.OpenRead(configFile); XMLArchiverIn archiverIn = new XMLArchiverIn(fis, "root"); archiverIn.Add(OPSObjectFactory.GetInstance()); OPSConfig newConfig = null; newConfig = (OPSConfig)archiverIn.Inout("ops_config", newConfig); fis.Close(); return(newConfig); }
public static OPSConfig GetConfig(string configFile) { try { FileStream fis = File.OpenRead(configFile); XMLArchiverIn archiverIn = new XMLArchiverIn(fis, "root"); archiverIn.Add(OPSObjectFactory.GetInstance()); OPSConfig newConfig = null; newConfig = (OPSConfig)archiverIn.Inout("ops_config", newConfig); fis.Close(); return(newConfig); } catch (FileNotFoundException) { Logger.ExceptionLogger.LogMessage("OPSConfig::GetConfig(), File NOT found: " + configFile); return(null); } }
//--------------------------------------------------------------- public Participant(string domainID, string participantID, string configFile) { Interlocked.Increment(ref safeInstanceCount); ///TEST this.domainID = domainID; this.participantID = participantID; try { if (configFile == "") { this.config = OPSConfig.GetConfig(); this.domain = this.config.GetDomain(domainID); } else { this.config = OPSConfig.GetConfig(configFile); this.domain = this.config.GetDomain(domainID); } if (this.domain != null) { this.inProcessTransport.Start(); SetupCyclicThread(); } else { Logger.ExceptionLogger.LogMessage(this.GetType().Name + ", Failed to find requested domain in configuration file"); throw new System.Exception("Failed to find requested domain in configuration file"); } } catch (IOException) { Logger.ExceptionLogger.LogMessage(this.GetType().Name + ", Configuration file missing"); throw; } catch (Ops.FormatException) { Logger.ExceptionLogger.LogMessage(this.GetType().Name + ", Format error in configuration file"); throw; } }
//--------------------------------------------------------------- public Participant(string domainID, string participantID, string configFile) { Interlocked.Increment(ref safeInstanceCount); ///TEST this.domainID = domainID; this.participantID = participantID; try { if (configFile == "") { this.config = OPSConfig.GetConfig(); this.domain = this.config.GetDomain(domainID); } else { this.config = OPSConfig.GetConfig(configFile); this.domain = this.config.GetDomain(domainID); } if (this.domain != null) { this.inProcessTransport.Start(); SetupCyclicThread(); } else { Logger.ExceptionLogger.LogMessage(this.GetType().Name + ", Failed to find requested domain in configuration file"); throw new System.Exception("Failed to find requested domain in configuration file"); } } catch (IOException) { Logger.ExceptionLogger.LogMessage(this.GetType().Name + ", Configuration file missing"); throw; } catch (Ops.FormatException) { Logger.ExceptionLogger.LogMessage(this.GetType().Name + ", Format error in configuration file"); throw; } }