/// <summary> /// Gets an existing service proxy or creates it if it doesn't exist. /// </summary> /// <returns>An instance of this service proxy.</returns> internal static ClubCloudServiceProxy GetOrCreateServiceProxy() { ClubCloudServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <ClubCloudServiceProxy>(); if (serviceProxy == null) { serviceProxy = new ClubCloudServiceProxy(SPFarm.Local); serviceProxy.Status = SPObjectStatus.Online; serviceProxy.Update(); } return(serviceProxy); }
/// <summary> /// Removes the service and components from the farm. /// </summary> internal static void RemoveService() { ClubCloudService service = SPFarm.Local.Services.GetValue <ClubCloudService>(); ClubCloudServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <ClubCloudServiceProxy>(); // Uninstall any service applications if (service != null) { foreach (SPServiceApplication app in service.Applications) { app.Unprovision(true); app.Delete(); } } // Uninstall any remaining service application proxies (e.g. any connections to other farms) if (serviceProxy != null) { foreach (SPServiceApplicationProxy proxy in serviceProxy.ApplicationProxies) { proxy.Unprovision(true); proxy.Delete(); } } // Uninstall the instances foreach (SPServer server in SPFarm.Local.Servers) { ClubCloudServiceInstance serviceInstance = server.ServiceInstances.GetValue <ClubCloudServiceInstance>(); while (serviceInstance != null) { server.ServiceInstances.Remove(serviceInstance.Id); serviceInstance = server.ServiceInstances.GetValue <ClubCloudServiceInstance>(); } } // Uninstall the service proxy if (serviceProxy != null) { SPFarm.Local.ServiceProxies.Remove(serviceProxy.Id); } // Uninstall the service if (service != null) { SPFarm.Local.Services.Remove(service.Id); } }
/// <summary> /// Initializes a new instance of the <see cref="ClubCloudServiceApplicationProxy"/> class. Use this constructor to create a new Service Application Proxy (e.g. from code on the Create page). /// </summary> /// <param name="name">The name of the Service Application Proxy to create. This name will not be localized.</param> /// <param name="serviceProxy">A reference to the Service Proxy class.</param> /// <param name="serviceEndpointUri">The endpoint uri to the service.</param> internal ClubCloudServiceApplicationProxy(string name, ClubCloudServiceProxy serviceProxy, Uri serviceEndpointUri) : base(name, serviceProxy, serviceEndpointUri) { this.loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceEndpointUri); }