예제 #1
0
        public static void Stop()
        {
            Log.Information("ServiceHelper Stop called");

            ISettings s = Settings.LoadSettings();

            CriticalProcessBase.SetProcessAsNotCritical(s);

            FirewallRule.AllowConnection(true);

            RegistryWrapper.StopRegistryMonitor();

            RegistryWrapper.RestoreDefaultSettings(true);

            Log.Information("Closing WCF Host");

            host?.Close();

            if (host is null)
            {
                Log.Information("Host was null");
            }

            if (host != null)
            {
                Log.Information("WCF Host status = " + host.State);
            }
        }
예제 #2
0
        public static void Initialize()
        {
            Log.Information("ServiceHelper Initialize called");

            if (UserHasAdminPrivileges() == false)
            {
                return;
            }

            ISettings s = Settings.LoadSettings();

            FirewallRule.AllowConnection(true);

            RegistryWrapper.StartRegistryMonitor();

            UnplugJob.Begin(s);

            Log.Information("Initializing WCF Host");

            host = new ServiceHost(typeof(WCF), new Uri("http://localhost:8022/UPService"));

            ServiceMetadataBehavior smb = host.Description.Behaviors.Find <ServiceMetadataBehavior>();

            if (smb == null)
            {
                smb = new ServiceMetadataBehavior();
            }

            host.Description.Behaviors.Add(smb);

            host.AddServiceEndpoint(typeof(IWCF), new BasicHttpBinding(), "");

            host.Open();

            Log.Information("WCF Host status = " + host.State);
        }