/// <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(NVRConfigService 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)
                {
                    ConfigServiceInstance instance = server.ServiceInstances.GetValue<ConfigServiceInstance>();
                    if (instance == null)
                    {
                        instance = new ConfigServiceInstance(server, service);
                        instance.Update();
                    }
                }
            }
        }
示例#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 NVRConfigService GetOrCreateService()
        {
            NVRConfigService service = SPFarm.Local.Services.GetValue<NVRConfigService>();
            if (service == null)
            {
                service = new NVRConfigService(SPFarm.Local);
                service.Status = SPObjectStatus.Online;
                service.Update();
            }

            return service;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigServiceInstance"/> 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 ConfigServiceInstance(SPServer server, NVRConfigService service)
     : base(server, service)
 {
 }