Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------

        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;
            }
        }