static void Main(string[] args) { ServiceHostDecorator host = null; try { CustomWsServiceHost stsHost = new CustomWsServiceHost(new CustomSecurityTokenServiceConfiguration()); stsHost.Open(); Console.WriteLine(); Console.WriteLine(string.Format("Security Token Service Started at {0}...", stsHost.BaseAddresses[0].ToString())); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { try { if (host.State == CommunicationState.Faulted) { host.Close(); } } catch { } } Console.ReadLine(); }
static void Main(string[] args) { Configuration.Configure(); ServiceHostDecorator AuthenticationServiceHost = new ServiceHostDecorator(typeof(AuthenticationService)); ServiceHostDecorator AuthorizationServiceHost = new ServiceHostDecorator(typeof(AuthorizationService)); ServiceHostDecorator GroupServiceHost = new ServiceHostDecorator(typeof(GroupService)); ServiceHostDecorator ManagementServiceHost = new ServiceHostDecorator(typeof(ManagementService)); ServiceHostDecorator MembershipProviderServiceHost = new ServiceHostDecorator(typeof(MembershipProviderService)); ServiceHostDecorator PermissionServiceHost = new ServiceHostDecorator(typeof(PermissionService)); ServiceHostDecorator ResourceServiceHost = new ServiceHostDecorator(typeof(ResourceService)); ServiceHostDecorator RoleServiceHost = new ServiceHostDecorator(typeof(RoleService)); ServiceHostDecorator SecurityUserServiceHost = new ServiceHostDecorator(typeof(SecurityUserService)); ServiceHostDecorator DataServiceHost = new ServiceHostDecorator(typeof(DataService)); ServiceHostDecorator ApplicationDomainServiceHost = new ServiceHostDecorator(typeof(ApplicationDomainService)); ServiceHostDecorator OperationServiceHost = new ServiceHostDecorator(typeof(OperationService)); ServiceHostDecorator SecurityCompanyHost = new ServiceHostDecorator(typeof(SecurityCompanyService)); try { LogManager.GetLogger().Info("Service Opened."); RoleServiceHost.Open(); Console.WriteLine(RoleServiceHost.OpenMessage); AuthenticationServiceHost.Open(); Console.WriteLine(AuthenticationServiceHost.OpenMessage); AuthorizationServiceHost.Open(); Console.WriteLine(AuthorizationServiceHost.OpenMessage); GroupServiceHost.Open(); Console.WriteLine(GroupServiceHost.OpenMessage); ManagementServiceHost.Open(); Console.WriteLine(ManagementServiceHost.OpenMessage); MembershipProviderServiceHost.Open(); Console.WriteLine(MembershipProviderServiceHost.OpenMessage); PermissionServiceHost.Open(); Console.WriteLine(PermissionServiceHost.OpenMessage); ResourceServiceHost.Open(); Console.WriteLine(ResourceServiceHost.OpenMessage); SecurityUserServiceHost.Open(); Console.WriteLine(SecurityUserServiceHost.OpenMessage); DataServiceHost.Open(); Console.WriteLine(DataServiceHost.OpenMessage); ApplicationDomainServiceHost.Open(); Console.WriteLine(ApplicationDomainServiceHost.OpenMessage); OperationServiceHost.Open(); Console.WriteLine(OperationServiceHost.OpenMessage); SecurityCompanyHost.Open(); Console.WriteLine(SecurityCompanyHost.OpenMessage); Console.WriteLine("Press <Enter> to stop the services"); Console.ReadKey(); //****************************************************************** } catch (Exception ex) { // log exception LogManager.GetLogger().Error(ex); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } finally { if (RoleServiceHost.State != CommunicationState.Faulted) { RoleServiceHost.Close(); } if (AuthenticationServiceHost.State != CommunicationState.Faulted) { AuthenticationServiceHost.Close(); } if (AuthorizationServiceHost.State != CommunicationState.Faulted) { AuthorizationServiceHost.Close(); } if (GroupServiceHost.State != CommunicationState.Faulted) { GroupServiceHost.Close(); } if (ManagementServiceHost.State != CommunicationState.Faulted) { ManagementServiceHost.Close(); } if (MembershipProviderServiceHost.State != CommunicationState.Faulted) { MembershipProviderServiceHost.Close(); } if (PermissionServiceHost.State != CommunicationState.Faulted) { PermissionServiceHost.Close(); } if (ResourceServiceHost.State != CommunicationState.Faulted) { ResourceServiceHost.Close(); } if (SecurityUserServiceHost.State != CommunicationState.Faulted) { SecurityUserServiceHost.Close(); } if (DataServiceHost.State != CommunicationState.Faulted) { DataServiceHost.Close(); } if (ApplicationDomainServiceHost.State != CommunicationState.Faulted) { ApplicationDomainServiceHost.Close(); } if (OperationServiceHost.State != CommunicationState.Faulted) { OperationServiceHost.Close(); } if (SecurityCompanyHost.State != CommunicationState.Faulted) { SecurityCompanyHost.Close(); } LogManager.GetLogger().Info("Service Closed."); } }
protected override void OnStart(string[] args) { if (AuthenticationServiceHost != null) { AuthenticationServiceHost.Close(); } if (AuthorizationServiceHost != null) { AuthorizationServiceHost.Close(); } if (GroupServiceHost != null) { GroupServiceHost.Close(); } if (ManagementServiceHost != null) { ManagementServiceHost.Close(); } if (MembershipProviderServiceHost != null) { MembershipProviderServiceHost.Close(); } if (PermissionServiceHost != null) { PermissionServiceHost.Close(); } if (ResourceServiceHost != null) { ResourceServiceHost.Close(); } if (RoleServiceHost != null) { RoleServiceHost.Close(); } if (SecurityUserServiceHost != null) { SecurityUserServiceHost.Close(); } if (DataServiceHost != null) { DataServiceHost.Close(); } if (ApplicationDomainServiceHost != null) { ApplicationDomainServiceHost.Close(); } if (OperationServiceHost != null) { OperationServiceHost.Close(); } if (SecurityCompanyHost != null) { SecurityCompanyHost.Close(); } AuthenticationServiceHost = new ServiceHostDecorator(typeof(AuthenticationService)); AuthorizationServiceHost = new ServiceHostDecorator(typeof(AuthorizationService)); GroupServiceHost = new ServiceHostDecorator(typeof(GroupService)); ManagementServiceHost = new ServiceHostDecorator(typeof(ManagementService)); MembershipProviderServiceHost = new ServiceHostDecorator(typeof(MembershipProviderService)); PermissionServiceHost = new ServiceHostDecorator(typeof(PermissionService)); ResourceServiceHost = new ServiceHostDecorator(typeof(ResourceService)); RoleServiceHost = new ServiceHostDecorator(typeof(RoleService)); SecurityUserServiceHost = new ServiceHostDecorator(typeof(SecurityUserService)); DataServiceHost = new ServiceHostDecorator(typeof(DataService)); ApplicationDomainServiceHost = new ServiceHostDecorator(typeof(ApplicationDomainService)); OperationServiceHost = new ServiceHostDecorator(typeof(OperationService)); SecurityCompanyHost = new ServiceHostDecorator(typeof(SecurityCompanyService)); try { LogManager.GetLogger().Info("Service Opened."); RoleServiceHost.Open(); AuthenticationServiceHost.Open(); AuthorizationServiceHost.Open(); GroupServiceHost.Open(); ManagementServiceHost.Open(); MembershipProviderServiceHost.Open(); PermissionServiceHost.Open(); ResourceServiceHost.Open(); SecurityUserServiceHost.Open(); DataServiceHost.Open(); ApplicationDomainServiceHost.Open(); OperationServiceHost.Open(); SecurityCompanyHost.Open(); //****************************************************************** } catch (Exception ex) { // log exception LogManager.GetLogger().Error(ex); } }
protected override void OnStop() { if (AuthenticationServiceHost != null) { AuthenticationServiceHost.Close(); AuthenticationServiceHost = null; } if (AuthorizationServiceHost != null) { AuthorizationServiceHost.Close(); AuthorizationServiceHost = null; } if (GroupServiceHost != null) { GroupServiceHost.Close(); GroupServiceHost = null; } if (ManagementServiceHost != null) { ManagementServiceHost.Close(); ManagementServiceHost = null; } if (MembershipProviderServiceHost != null) { MembershipProviderServiceHost.Close(); MembershipProviderServiceHost = null; } if (PermissionServiceHost != null) { PermissionServiceHost.Close(); PermissionServiceHost = null; } if (ResourceServiceHost != null) { ResourceServiceHost.Close(); ResourceServiceHost = null; } if (RoleServiceHost != null) { RoleServiceHost.Close(); RoleServiceHost = null; } if (SecurityUserServiceHost != null) { SecurityUserServiceHost.Close(); SecurityUserServiceHost = null; } if (DataServiceHost != null) { DataServiceHost.Close(); DataServiceHost = null; } if (ApplicationDomainServiceHost != null) { ApplicationDomainServiceHost.Close(); ApplicationDomainServiceHost = null; } if (OperationServiceHost != null) { OperationServiceHost.Close(); OperationServiceHost = null; } if (SecurityCompanyHost != null) { SecurityCompanyHost.Close(); SecurityCompanyHost = null; } LogManager.GetLogger().Info("Service Closed."); }
static void Main(string[] args) { Configuration.Configure(); ServiceHostDecorator ServiceJobServiceHost = new ServiceHostDecorator(typeof(ServiceJobService)); ServiceHostDecorator ServiceCategoryHost = new ServiceHostDecorator(typeof(ServiceCategoryService)); ServiceHostDecorator BaseDataServiceHost = new ServiceHostDecorator(typeof(BaseDataService)); ServiceHostDecorator ServiceCategoryJobHost = new ServiceHostDecorator(typeof(ServiceCategoryJobService)); ServiceHostDecorator UserRequestHost = new ServiceHostDecorator(typeof(UserRequestService)); ServiceHostDecorator worktHost = new ServiceHostDecorator(typeof(WorkService)); ServiceHostDecorator officeHost = new ServiceHostDecorator(typeof(OfficeService)); ServiceHostDecorator roleHost = new ServiceHostDecorator(typeof(RoleService)); ServiceHostDecorator cartableHost = new ServiceHostDecorator(typeof(ServiceDeskCartableService)); try { LogManager.GetLogger().Info("Service Opened."); ServiceJobServiceHost.Open(); Console.WriteLine(ServiceJobServiceHost.OpenMessage); ServiceCategoryHost.Open(); Console.WriteLine(ServiceCategoryHost.OpenMessage); BaseDataServiceHost.Open(); Console.WriteLine(BaseDataServiceHost.OpenMessage); ServiceCategoryJobHost.Open(); Console.WriteLine(ServiceCategoryJobHost.OpenMessage); UserRequestHost.Open(); Console.WriteLine(UserRequestHost.OpenMessage); worktHost.Open(); Console.WriteLine(worktHost.OpenMessage); officeHost.Open(); Console.WriteLine(officeHost.OpenMessage); roleHost.Open(); Console.WriteLine(roleHost.OpenMessage); cartableHost.Open(); Console.WriteLine(cartableHost.OpenMessage); Console.WriteLine("Press <Enter> to stop the services"); Console.ReadKey(); //****************************************************************** } catch (Exception ex) { // log exception LogManager.GetLogger().Error(ex); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } finally { if (ServiceJobServiceHost.State != CommunicationState.Faulted) { ServiceJobServiceHost.Close(); } if (ServiceCategoryHost.State != CommunicationState.Faulted) { ServiceCategoryHost.Close(); } if (BaseDataServiceHost.State != CommunicationState.Faulted) { BaseDataServiceHost.Close(); } if (ServiceCategoryJobHost.State != CommunicationState.Faulted) { ServiceCategoryJobHost.Close(); } if (ServiceCategoryJobHost.State != CommunicationState.Faulted) { ServiceCategoryJobHost.Close(); } if (worktHost.State != CommunicationState.Faulted) { worktHost.Close(); } if (officeHost.State != CommunicationState.Faulted) { officeHost.Close(); } if (roleHost.State != CommunicationState.Faulted) { roleHost.Close(); } if (cartableHost.State != CommunicationState.Faulted) { cartableHost.Close(); } LogManager.GetLogger().Info("Service Closed."); } }