/// <summary>
        /// Initializes the datastore with the server configuration.
        /// </summary>
        /// <param name="serverDescription">The server description.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="certificateValidator">The certificate validator.</param>
        /// <param name="instanceCertificate">The instance certificate.</param>
        public ServerInternalData(
            ServerProperties serverDescription,
            ApplicationConfiguration configuration,
            IServiceMessageContext messageContext,
            CertificateValidator certificateValidator,
            X509Certificate2 instanceCertificate)
        {
            m_serverDescription = serverDescription;
            m_configuration     = configuration;
            m_messageContext    = messageContext;

            m_endpointAddresses = new List <Uri>();

            foreach (string baseAddresses in m_configuration.ServerConfiguration.BaseAddresses)
            {
                Uri url = Utils.ParseUri(baseAddresses);

                if (url != null)
                {
                    m_endpointAddresses.Add(url);
                }
            }

            m_namespaceUris = m_messageContext.NamespaceUris;
            m_factory       = m_messageContext.Factory;

            m_serverUris = new StringTable();
            m_typeTree   = new TypeTable(m_namespaceUris);

            // add the server uri to the server table.
            m_serverUris.Append(m_configuration.ApplicationUri);

            // create the default system context.
            m_defaultSystemContext = new ServerSystemContext(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an encoder to save Variant values.
        /// </summary>
        private XmlEncoder CreateEncoder(ISystemContext context)
        {
            IServiceMessageContext messageContext = new ServiceMessageContext()
            {
                NamespaceUris = context.NamespaceUris,
                ServerUris    = context.ServerUris,
                Factory       = context.EncodeableFactory
            };

            XmlEncoder encoder = new XmlEncoder(messageContext);

            NamespaceTable namespaceUris = new NamespaceTable();

            if (NamespaceUris != null)
            {
                for (int ii = 0; ii < NamespaceUris.Length; ii++)
                {
                    namespaceUris.Append(NamespaceUris[ii]);
                }
            }

            StringTable serverUris = new StringTable();

            if (ServerUris != null)
            {
                serverUris.Append(context.ServerUris.GetString(0));

                for (int ii = 0; ii < ServerUris.Length; ii++)
                {
                    serverUris.Append(ServerUris[ii]);
                }
            }

            encoder.SetMappingTables(namespaceUris, serverUris);

            return(encoder);
        }
        /// <summary>
        /// Creates an decoder to restore Variant values.
        /// </summary>
        private XmlDecoder CreateDecoder(ISystemContext context, XmlElement source)
        {
            ServiceMessageContext messageContext = new ServiceMessageContext();

            messageContext.NamespaceUris = context.NamespaceUris;
            messageContext.ServerUris    = context.ServerUris;
            messageContext.Factory       = context.EncodeableFactory;

            XmlDecoder decoder = new XmlDecoder(source, messageContext);

            NamespaceTable namespaceUris = new NamespaceTable();

            if (NamespaceUris != null)
            {
                for (int ii = 0; ii < NamespaceUris.Length; ii++)
                {
                    namespaceUris.Append(NamespaceUris[ii]);
                }
            }

            StringTable serverUris = new StringTable();

            if (ServerUris != null)
            {
                serverUris.Append(context.ServerUris.GetString(0));

                for (int ii = 0; ii < ServerUris.Length; ii++)
                {
                    serverUris.Append(ServerUris[ii]);
                }
            }

            decoder.SetMappingTables(namespaceUris, serverUris);

            return(decoder);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructs the server.
        /// </summary>
        public ServerObject(string applicationUri, NodeManager nodeManager)
        {
            // the namespace table is used for the namepace indexes in NodeIds and QualifiedNames
            // The first index (added by default) is the UA namespace. The second is the application uri.
            m_namespaceUris = new NamespaceTable();
            m_namespaceUris.Append(applicationUri);

            // the server table is used for the server index in remote NodeIds (a.k.a. ExpandedNodeIds)
            // The first index is always the current server.
            m_serverUris = new StringTable();
            m_serverUris.Append(applicationUri);

            m_serviceLevel = 100;

            m_serverStatus                     = new ServerStatusDataType();
            m_serverStatus.StartTime           = DateTime.UtcNow;
            m_serverStatus.CurrentTime         = DateTime.UtcNow;
            m_serverStatus.State               = ServerState.Running_0;
            m_serverStatus.SecondsTillShutdown = 0;
            m_serverStatus.ShutdownReason      = null;

            m_serverStatus.BuildInfo                  = new BuildInfo();
            m_serverStatus.BuildInfo.BuildDate        = new DateTime(2008, 7, 1);
            m_serverStatus.BuildInfo.SoftwareVersion  = "1.00";
            m_serverStatus.BuildInfo.BuildNumber      = "218.0";
            m_serverStatus.BuildInfo.ManufacturerName = "My Company";
            m_serverStatus.BuildInfo.ProductName      = "My Sample Server";
            m_serverStatus.BuildInfo.ProductUri       = "http://mycompany.com/MySampleServer/v1.0";

            // tell the node manager to call this object whenever the value of these attributes are read.
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_NamespaceArray), GetNamespaceArray);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerArray), GetServerArray);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServiceLevel), GetServiceLevel);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus), GetServerStatus);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus_StartTime), GetServerStatus_StartTime);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus_CurrentTime), GetServerStatus_CurrentTime);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus_State), GetServerStatus_State);
        }
Esempio n. 5
0
        /// <summary>
        /// Constructs the server.
        /// </summary>
        public ServerObject(string applicationUri, NodeManager nodeManager)
        {
            // the namespace table is used for the namepace indexes in NodeIds and QualifiedNames
            // The first index (added by default) is the UA namespace. The second is the application uri.
            m_namespaceUris = new NamespaceTable();
            m_namespaceUris.Append(applicationUri);

            // the server table is used for the server index in remote NodeIds (a.k.a. ExpandedNodeIds)
            // The first index is always the current server.
            m_serverUris = new StringTable();
            m_serverUris.Append(applicationUri);

            m_serviceLevel = 100;

            m_serverStatus = new ServerStatusDataType();
            m_serverStatus.StartTime = DateTime.UtcNow;
            m_serverStatus.CurrentTime = DateTime.UtcNow;
            m_serverStatus.State = ServerState.Running_0;
            m_serverStatus.SecondsTillShutdown = 0;
            m_serverStatus.ShutdownReason = null;

            m_serverStatus.BuildInfo = new BuildInfo();
            m_serverStatus.BuildInfo.BuildDate = new DateTime(2008, 7, 1);
            m_serverStatus.BuildInfo.SoftwareVersion = "1.00";
            m_serverStatus.BuildInfo.BuildNumber = "218.0";
            m_serverStatus.BuildInfo.ManufacturerName = "My Company";
            m_serverStatus.BuildInfo.ProductName = "My Sample Server";
            m_serverStatus.BuildInfo.ProductUri = "http://mycompany.com/MySampleServer/v1.0";

            // tell the node manager to call this object whenever the value of these attributes are read.
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_NamespaceArray), GetNamespaceArray);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerArray), GetServerArray);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServiceLevel), GetServiceLevel);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus), GetServerStatus);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus_StartTime), GetServerStatus_StartTime);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus_CurrentTime), GetServerStatus_CurrentTime);
            nodeManager.SetReadValueCallback(new NodeId(Variables.Server_ServerStatus_State), GetServerStatus_State);
        }
        /// <summary>
        /// Initializes the datastore with the server configuration.
        /// </summary>
        /// <param name="serverDescription">The server description.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="certificateValidator">The certificate validator.</param>
        /// <param name="instanceCertificate">The instance certificate.</param>
        public ServerInternalData(
            ServerProperties                     serverDescription, 
            ApplicationConfiguration             configuration,
            ServiceMessageContext                messageContext,
            CertificateValidator                 certificateValidator,
            X509Certificate2                     instanceCertificate)
        {
            m_serverDescription = serverDescription;
            m_configuration = configuration;
            m_messageContext = messageContext;
            
            m_endpointAddresses = new List<Uri>();

            foreach (string baseAddresses in m_configuration.ServerConfiguration.BaseAddresses)
            {
                Uri url = Utils.ParseUri(baseAddresses);

                if (url != null)
                {
                    m_endpointAddresses.Add(url);
                }
            }
            
            m_namespaceUris = m_messageContext.NamespaceUris;
            m_factory = m_messageContext.Factory;

            m_serverUris = new StringTable();
            m_typeTree = new TypeTable(m_namespaceUris);

#if LEGACY_CORENODEMANAGER
            m_typeSources = new TypeSourceTable();
#endif
                                                
            // add the server uri to the server table.
            m_serverUris.Append(m_configuration.ApplicationUri);

            // create the default system context.
            m_defaultSystemContext = new ServerSystemContext(this);
        }
Esempio n. 7
0
        /// <summary>
        /// compares the new server namespace table with the (saved) table known to the client.  Provides a
        /// mapping for any namespaces which are new or removed and indices which have changed.
        /// </summary>
        /// <param name="clsid"></param>
        private void GenerateNamespaceIndexMappings(Guid clsid)
        {
            try
            {
                StringTable savedStringTable = new StringTable();
                for (int i = 0; i < m_configFile.SavedNamespaceTable.Length; i++)
                    savedStringTable.Append(m_configFile.SavedNamespaceTable[i]);

                NamespaceTable serverNamespaceTable = m_session.NamespaceUris;
                string[] serverNamespaceArray = serverNamespaceTable.ToArray();

                for (int i = 0; i < serverNamespaceArray.Length; i++)
                {
                    // Generate the serverIndex->clientIndex mapping table.  Update the client namespace
                    // table in the process if new namespaces have been added to the server namespace
                    m_serverMappingTable.Add(savedStringTable.GetIndexOrAppend(serverNamespaceArray[i]));
                }

                m_configFile.SavedNamespaceTable = savedStringTable.ToArray();

                for (int i = 0; i < m_configFile.SavedNamespaceTable.Length; i++)
                {
                    // Generate the clientIndex->serverIndex mapping table
                    m_clientmappingTable.Add(serverNamespaceTable.GetIndex(m_configFile.SavedNamespaceTable[i]));
                }

            }
            catch (Exception e)
            {
                Utils.Trace(e, "Unexpected error in InitNamespaceMappingTable");
            }
        }
        /// <summary>
        /// Creates an decoder to restore Variant values.
        /// </summary>
        private XmlDecoder CreateDecoder(ISystemContext context, XmlElement source)
        {
            ServiceMessageContext messageContext = new ServiceMessageContext();
            messageContext.NamespaceUris = context.NamespaceUris;
            messageContext.ServerUris = context.ServerUris;
            messageContext.Factory = context.EncodeableFactory;

            XmlDecoder decoder = new XmlDecoder(source, messageContext);

            NamespaceTable namespaceUris = new NamespaceTable();

            if (NamespaceUris != null)
            {
                for (int ii = 0; ii < NamespaceUris.Length; ii++)
                {
                    namespaceUris.Append(NamespaceUris[ii]);
                }
            }

            StringTable serverUris = new StringTable();

            if (ServerUris != null)
            {
                serverUris.Append(context.ServerUris.GetString(0));

                for (int ii = 0; ii < ServerUris.Length; ii++)
                {
                    serverUris.Append(ServerUris[ii]);
                }
            }

            decoder.SetMappingTables(namespaceUris, serverUris);

            return decoder;
        }