Opc.Ua.Configuration.PseudoComServer.Import C# (CSharp) Method

Import() public static method

Imports the configured endpoints from a collection saved on disk.
public static Import ( string filePath ) : string
filePath string The file path.
return string
        public static string Import(string filePath)
        {
            StringBuilder errors = new StringBuilder();

            ConfiguredEndpointCollection collection = ConfiguredEndpointCollection.Load(filePath);

            int loaded = 0;
            int imported = 0;

            foreach (ConfiguredEndpoint endpoint in collection.Endpoints)
            {
                loaded++;

                try
                {
                    Save(endpoint);
                    imported++;
                }
                catch (Exception e)
                {
                    if (errors.Length > 0)
                    {
                        errors.AppendFormat("\r\n");
                    }

                    errors.AppendFormat("Endpoint #{0} - {1}", loaded, e.Message);
                }
            }

            if (errors.Length > 0)
            {
                errors.AppendFormat("\r\n\r\n{0} of {0} endpoints imported successfully.", imported, loaded);
            }

            return errors.ToString();
        }