/// <summary>
        /// Construct the object by de-serializing from the stream.
        /// </summary>
        protected OpcConnectData(SerializationInfo info, StreamingContext context)
        {
            string username = info.GetString(Names.UserName);
            string password = info.GetString(Names.Password);
            string domain   = info.GetString(Names.Domain);
            string proxyUri = info.GetString(Names.ProxyUri);

            info.GetString(Names.LicenseKey);

            if (domain != null)
            {
                UserIdentity = new OpcUserIdentity("", "");
            }
            else
            {
                UserIdentity = new OpcUserIdentity(username, password);
            }

            if (proxyUri != null)
            {
                proxy_ = new WebProxy(proxyUri);
            }
            else
            {
                proxy_ = null;
            }
        }
        /// <summary>
        /// Contructs teh object by de-serializing from the stream.
        /// </summary>
        protected OpcConnectData(SerializationInfo info, StreamingContext context)
        {
            string username   = info.GetString(Names.USER_NAME);
            string password   = info.GetString(Names.PASSWORD);
            string domain     = info.GetString(Names.DOMAIN);
            string proxyUri   = info.GetString(Names.PROXY_URI);
            string licenseKey = info.GetString(Names.LICENSE_KEY);

            if (domain != null)
            {
                UserIdentity = new OpcUserIdentity("", "");
            }
            else
            {
                UserIdentity = new OpcUserIdentity(username, password);
            }

            if (proxyUri != null)
            {
                _proxy = new WebProxy(proxyUri);
            }
            else
            {
                _proxy = null;
            }
        }
        ///////////////////////////////////////////////////////////////////////
        #region Public Methods

        /// <summary>
        /// Whether the identity represents an the default identity.
        /// </summary>
        public static bool IsDefault(OpcUserIdentity identity)
        {
            if (identity != null)
            {
                return(!identity._usernameValid);
            }

            return(true);
        }
 /// <summary>
 /// Initializes an instance with the specified credentials.
 /// </summary>
 public OpcConnectData(OpcUserIdentity userIdentity)
 {
     UserIdentity = userIdentity;
     proxy_       = null;
 }
 /// <summary>
 /// Initializes an instance with the specified credentials and web proxy.
 /// </summary>
 public OpcConnectData(OpcUserIdentity userIdentity, WebProxy proxy)
 {
     UserIdentity = userIdentity;
     proxy_       = proxy;
 }
Example #6
0
        /// <summary>
        /// Returns a list of servers that support the specified specification.
        /// </summary>
        /// <param name="specification">Unique identifier for one OPC specification.</param>
        /// <param name="discoveryServerUrl">The URL of the discovery server to be used.</param>
        /// <param name="identity">The user identity to use when discovering the servers.</param>
        /// <returns>Returns a list of found OPC servers.</returns>
        public static List <OpcServer> GetServers(OpcSpecification specification, string discoveryServerUrl, OpcUserIdentity identity)
        {
            List <OpcServer> serverList = new List <OpcServer>();

            bool discovery = specification == OpcSpecification.OPC_AE_10 || (specification == OpcSpecification.OPC_DA_20 ||
                                                                             specification == OpcSpecification.OPC_DA_30) || specification == OpcSpecification.OPC_HDA_10;

            if (discovery)
            {
                if (discovery_ == null || hostName_ != discoveryServerUrl)
                {
                    discovery_?.Dispose();
                    hostName_  = discoveryServerUrl;
                    discovery_ = new ServerEnumerator();
                }

                OpcServer[] servers = discovery_.GetAvailableServers(specification);

                if (servers != null)
                {
                    foreach (OpcServer server in servers)
                    {
                        serverList.Add(server);
                    }
                }
            }

            return(serverList);
        }
Example #7
0
        /// <summary>
        /// Returns a list of servers that support the specified specification.
        /// </summary>
        /// <param name="specification">Unique identifier for one OPC specification.</param>
        /// <param name="discoveryServerUrl">The URL of the discovery server to be used.</param>
        /// <returns>Returns a list of found OPC servers.</returns>
        public static List <OpcServer> GetServers(OpcSpecification specification, string discoveryServerUrl)
        {
            OpcUserIdentity identity = new OpcUserIdentity("", "");

            return(GetServers(specification, discoveryServerUrl, identity));
        }
Example #8
0
        /// <summary>
        /// Returns a list of servers that support the specified specification.
        /// </summary>
        /// <param name="specification">Unique identifier for one OPC specification.</param>
        /// <returns>Returns a list of found OPC servers.</returns>
        public static List <OpcServer> GetServers(OpcSpecification specification)
        {
            OpcUserIdentity identity = new OpcUserIdentity("", "");

            return(GetServers(specification, null, identity));
        }
        /// <summary>
        /// Returns a list of servers that support the specified specification.
        /// </summary>
        /// <param name="specification">Unique identifier for one OPC specification.</param>
        /// <param name="discoveryServerUrl">The URL of the discovery server to be used.</param>
        /// <param name="identity">The user identity to use when discovering the servers.</param>
        /// <returns>Returns a list of found OPC servers.</returns>
        public static List <OpcServer> GetServers(OpcSpecification specification, string discoveryServerUrl, OpcUserIdentity identity)
        {
            List <OpcServer> serverList = new List <OpcServer>();

            bool dcomDiscovery = false;

            if (specification == OpcSpecification.OPC_AE_10)
            {
                dcomDiscovery = true;
            }
            if (specification == OpcSpecification.OPC_DA_20 ||
                specification == OpcSpecification.OPC_DA_30)
            {
                dcomDiscovery = true;
            }
            if (specification == OpcSpecification.OPC_HDA_10)
            {
                dcomDiscovery = true;
            }

            if (specification == null)
            {
                return(serverList);
            }
            else if (dcomDiscovery)
            {
                if (_discovery == null || _hostName != discoveryServerUrl)
                {
                    if (_discovery != null)
                    {
                        _discovery.Dispose();
                    }
                    _hostName  = discoveryServerUrl;
                    _discovery = new Technosoftware.DaAeHdaClient.Com.ServerEnumerator();
                }

                OpcServer[] servers = _discovery.GetAvailableServers(specification);

                if (servers != null)
                {
                    foreach (OpcServer server in servers)
                    {
                        serverList.Add(server);
                    }
                }
            }

            return(serverList);
        }