Beispiel #1
0
        /// <summary>
        /// Loads a specified Petra Module Instantiator DLL into a Client's AppDomain,
        /// initialises the main Class (an Instantiator) and remotes the resulting
        /// Instantiator Object.
        ///
        /// </summary>
        /// <param name="AClientID"></param>
        /// <param name="AAssemblyDLLName">name of the dll that contains ARemoteType</param>
        /// <param name="ARemoteType">name of the class that should be loaded</param>
        /// <param name="APetraModuleInstantiatorRemotingURL">The .NET Remoting URL which the
        /// Client needs to make calls to the Instantiator Object.
        /// </param>
        public void LoadPetraModuleAssembly(String AClientID,
                                            String AAssemblyDLLName,
                                            string ARemoteType,
                                            out String APetraModuleInstantiatorRemotingURL)
        {
            ICrossDomainService RemoteObject;

            FRemoteLoader.LoadPetraModuleAssembly(
                AAssemblyDLLName,
                ARemoteType,
                out APetraModuleInstantiatorRemotingURL,
                out RemoteObject);

            // register the remote url at the CrossDomainMarshaller
            TCrossDomainMarshaller.AddService(AClientID, APetraModuleInstantiatorRemotingURL, RemoteObject);

            if (TLogging.DL >= 10)
            {
                TLogging.Log(
                    "Loaded Assemblies in AppDomain " + AppDomain.CurrentDomain.FriendlyName +
                    ": (after instantiation of " + ARemoteType + ")",
                    TLoggingType.ToConsole | TLoggingType.ToLogfile);

                foreach (Assembly tmpAssembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    TLogging.Log(tmpAssembly.FullName, TLoggingType.ToConsole | TLoggingType.ToLogfile);
                }
            }
        }
        /// <summary>
        /// process message
        /// </summary>
        public IMessage SyncProcessMessage(IMessage msg)
        {
            if (msg.Properties["__Uri"] == null)
            {
                return(this.nextSink.SyncProcessMessage(msg));
            }
            else
            {
                LogicalCallContext callContext = (LogicalCallContext)msg.Properties["__CallContext"];

                if ((callContext.GetData("__ClientID") != null) && (callContext.GetData("__ServiceID") != null))
                {
                    string clientID  = (string)callContext.GetData("__ClientID");
                    string serviceID = (string)callContext.GetData("__ServiceID");

                    if (TLogging.DebugLevel >= 10)
                    {
                        TLogging.Log("SyncProcessMessage: " + clientID + " " + serviceID);
                    }

                    return(TCrossDomainMarshaller.GetService(clientID, serviceID).Marshal(msg));
                }
                else
                {
                    // TLogging.Log("SyncProcessMessage: No __ClientID or __ServiceID");
                    return(new ReturnMessage(
                               new EOPAppException("No __ClientID or __ServiceID"),
                               (IMethodCallMessage)msg));
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Loads the ClientDomain DLL into the Client's AppDomain, instantiates the
        /// main Class (TClientDomainManager) and initialises the AppDomain by calling
        /// several functions of that Class.
        ///
        /// </summary>
        /// <param name="AClientID">ClientID as assigned by the ClientManager</param>
        /// <param name="AClientServerConnectionType">Tells in which way the Client connected
        /// to the PetraServer</param>
        /// <param name="AClientManagerRef">A reference to the ClientManager object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ASystemDefaultsCacheRef">A reference to the SystemDefaultsCache object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ACacheableTablesManagerRef"></param>
        /// <param name="AUserInfo">An instantiated PetraPrincipal Object, containing User
        /// information</param>
        /// <param name="ARemotingURLPollClientTasks">the .NET Remoting URL of the
        /// TPollClientTasks Class which the Client needs to calls to retrieve
        /// ClientTasks.</param>
        /// <returns>void</returns>
        public void LoadDomainManagerAssembly(Int32 AClientID,
                                              TClientServerConnectionType AClientServerConnectionType,
                                              TClientManagerCallForwarder AClientManagerRef,
                                              object ASystemDefaultsCacheRef,
                                              object ACacheableTablesManagerRef,
                                              IPrincipal AUserInfo,
                                              out String ARemotingURLPollClientTasks)
        {
            ICrossDomainService RemoteObject;

            FRemoteLoader.LoadDomainManagerAssembly(AClientID,
                                                    AClientServerConnectionType,
                                                    AClientManagerRef,
                                                    ASystemDefaultsCacheRef,
                                                    ACacheableTablesManagerRef,
                                                    AUserInfo,
                                                    TSrvSetting.ServerSettings,
                                                    out ARemotingURLPollClientTasks,
                                                    out RemoteObject);

            // register the remote url at the CrossDomainMarshaller
            TCrossDomainMarshaller.AddService(AClientID.ToString(), ARemotingURLPollClientTasks, RemoteObject);

            // Load the CallForwinding DLL into the Client's AppDomain
            FRemoteLoader.LoadCallForwardingAssembly();

            // IMPORTANT: If the following code is uncommented, the ClientDomain DLL that is loaded only in the Client's AppDomain might get loaded into the Default AppDomain  that's what we don't want!!!
            // Use this therefore only to find out what DLL's are loaded in the Client's AppDomain!!!!!!
            if (TLogging.DL >= 10)
            {
                TLogging.Log(
                    "Loaded Assemblies in AppDomain " + AppDomain.CurrentDomain.FriendlyName + ": (after instantiation of TClientDomainManager)",
                    TLoggingType.ToConsole | TLoggingType.ToLogfile);

                foreach (Assembly tmpAssembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    TLogging.Log(tmpAssembly.FullName, TLoggingType.ToConsole | TLoggingType.ToLogfile);
                }
            }
        }
Beispiel #4
0
        /// Remote the remoteable objects
        static private void EstablishRemoting()
        {
            try
            {
                BinaryServerFormatterSinkProvider TCPSink = new BinaryServerFormatterSinkProvider();
                TCPSink.TypeFilterLevel = TypeFilterLevel.Low;
                IServerChannelSinkProvider EncryptionSink = TCPSink;

                if (TAppSettingsManager.GetValue("Server.ChannelEncryption.PrivateKeyfile", "", false).Length > 0)
                {
                    EncryptionSink = new EncryptionServerSinkProvider();
                    EncryptionSink.Next = TCPSink;
                }

                Hashtable ChannelProperties = new Hashtable();
                ChannelProperties.Add("port", TSrvSetting.IPBasePort);

                TcpChannel Channel = new TcpChannel(ChannelProperties, null, EncryptionSink);
                ChannelServices.RegisterChannel(Channel, false);

                RemotingConfiguration.RegisterWellKnownServiceType(typeof(Tests.IctCommonRemoting.Server.TServerManager),
                    "Servermanager", WellKnownObjectMode.Singleton);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(Ict.Common.Remoting.Server.TClientManager),
                    "Clientmanager", WellKnownObjectMode.Singleton);

                TheCrossDomainMarshaller = new TCrossDomainMarshaller();
                RemotingServices.Marshal(TheCrossDomainMarshaller, TClientManager.CROSSDOMAINURL);

                // register the services, independent of the appdomain which is per client
            }
            catch (RemotingException rex)
            {
                if (rex.Message.IndexOf("SocketException") > 1)
                {
                    TLogging.Log("A SocketException has been thrown.");
                    TLogging.Log("Most probably problem is that the address port is used twice!");
                    throw new EOPAppException();
                }
                else
                {
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }