示例#1
0
        /*public ProtokollerInstance()
         * {
         *  ProtokollerConfiguration.Load(false);
         *  this.akConfig = ProtokollerConfiguration.ActualConfigInstance;
         * }*/

        public void Start(bool StartedAsService)
        {
            //Remoting Server für Benachrichtigung an Client das neue Daten da sind

            /*remotingServer = new RemotingServer();
             * remotingServer.Start();*/

            if (akConfig.UseWebserver)
            {
                AspxVirtualRoot webServer = new AspxVirtualRoot(akConfig.WebserverPort);
                webServer.Configure("/", System.IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "web"));
            }

            if (akConfig.UseWCFService)
            {
                var serverName = "ProtocolService";
                var addressWeb = new Uri("http://localhost:" + akConfig.WCFServicePort + "/");

                wcfWebService = new WebServiceHost(this /*.GetType()*/, new Uri[] { addressWeb });

                wcfWebService.AddServiceEndpoint(typeof(IProtocolService), new BasicHttpBinding(), serverName);
                wcfWebService.AddServiceEndpoint(typeof(IPolicyRetriever), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior());

                wcfWebService.Open();
            }

            context = SynchronizationContext.Current;

            Logging.LogText("Protokoller gestartet", Logging.LogLevel.Information);
            EstablishConnections();
            OpenStoragesAndCreateTriggers(true, StartedAsService);

            synTimer = new Timer(synchronizePLCTimes, null, 0, 60000);
        }
示例#2
0
        public void Dispose()
        {
            Logging.LogText("Protokoller gestopt", Logging.LogLevel.Information);
            if (myReEstablishConnectionsThreads != null)
            {
                foreach (var myReEstablishConnectionsThread in myReEstablishConnectionsThreads)
                {
                    myReEstablishConnectionsThread.Abort();
                }
            }

            if (webServer != null)
            {
                webServer.StopListener();
                webServer.Dispose();
                webServer = null;
            }

            if (wcfWebService != null)
            {
                wcfWebService.Close();
                wcfWebService = null;
            }

            foreach (var disposable in myDisposables)
            {
                disposable.Dispose();
            }

            foreach (object conn in ConnectionList.Values)
            {
                if (conn is PLCConnection)
                {
                    ((PLCConnection)conn).Dispose();
                }
                else if (conn is TCPFunctionsAsync)
                {
                    ((TCPFunctionsAsync)conn).Dispose();
                }
            }

            foreach (IDBInterface dbInterface in DatabaseInterfaces.Values)
            {
                dbInterface.Close();
            }

            if (synTimer != null)
            {
                synTimer.Dispose();
            }
        }