/// <summary>
        /// Initializes a new instance of the <see cref="ClubCloudServiceApplication"/> class. Use this constructor when creating a new Service Application (e.g. from code in your Create page)
        /// </summary>
        /// <param name="name">The name of the service application.</param>
        /// <param name="service">The <see cref="ClubCloudService" />.</param>
        /// <param name="customDatabase">A custom database to associate with this service application.</param>
        /// <param name="applicationPool">The application pool.</param>
        internal ClubCloudServiceApplication(string name, ClubCloudService service, ClubCloudDatabase customDatabase, SPIisWebServiceApplicationPool applicationPool)
            : base(name, service, applicationPool)
        {
            if (customDatabase == null)
            {
                throw new ArgumentNullException("customDatabase");
            }

            this.database = customDatabase;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets an existing service or creates it if it doesn't exist.
        /// </summary>
        /// <returns>An instance of the Service.</returns>
        internal static ClubCloudService GetOrCreateService()
        {
            ClubCloudService service = SPFarm.Local.Services.GetValue <ClubCloudService>();

            if (service == null)
            {
                service        = new ClubCloudService(SPFarm.Local);
                service.Status = SPObjectStatus.Online;
                service.Update();
            }

            return(service);
        }
Ejemplo n.º 3
0
        /// <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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Installs the service instances on servers in the farm (does not start them).
        /// </summary>
        /// <param name="service">The service associated with these instances.</param>
        internal static void CreateServiceInstances(ClubCloudService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }

            foreach (SPServer server in SPFarm.Local.Servers)
            {
                if (server.Role == SPServerRole.Application || server.Role == SPServerRole.SingleServer || server.Role == SPServerRole.WebFrontEnd)
                {
                    ClubCloudServiceInstance instance = server.ServiceInstances.GetValue <ClubCloudServiceInstance>();
                    if (instance == null)
                    {
                        instance = new ClubCloudServiceInstance(server, service);
                        instance.Update();
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ClubCloudServiceApplication"/> class. Use this constructor when creating a new Service Application (e.g. from code in your Create page)
 /// </summary>
 /// <param name="name">The name of the service application.</param>
 /// <param name="service">The <see cref="ClubCloudService" />.</param>
 /// <param name="applicationPool">The application pool.</param>
 internal ClubCloudServiceApplication(string name, ClubCloudService service, SPIisWebServiceApplicationPool applicationPool)
     : base(name, service, applicationPool)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClubCloudServiceInstance"/> class. Use this constructor to install the service instance on servers in the farm.
 /// </summary>
 /// <param name="server">The SPServer to install the instance to.</param>
 /// <param name="service">The service to associate the service instance with.</param>
 internal ClubCloudServiceInstance(SPServer server, ClubCloudService service)
     : base(server, service)
 {
 }