예제 #1
0
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            // Uninstall the instance.
            //NodeServiceInstance serviceInstance = SPFarm.Local.Services.GetValue<NodeServiceInstance>();
            foreach (SPServer server in SPFarm.Local.Servers)
            {
                if (server.Role != SPServerRole.Invalid)
                {
                    NodeServiceInstance serviceInstance = server.ServiceInstances.GetValue <NodeServiceInstance>();

                    if (serviceInstance != null)
                    {
                        serviceInstance.Delete();
                    }
                }
            }

            // Uninstall the service proxy.
            NodeServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <NodeServiceProxy>();

            if (serviceProxy != null)
            {
                serviceProxy.Delete();
            }

            // Uninstall the service.
            NodeService service = SPFarm.Local.Services.GetValue <NodeService>();

            if (service != null)
            {
                service.Delete();
            }
        }
예제 #2
0
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            // Install the service.
            NodeService service = SPFarm.Local.Services.GetValue <NodeService>();

            if (service == null)
            {
                service = new NodeService(SPFarm.Local);
                service.Update();
            }

            // Install the service proxy.
            NodeServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <NodeServiceProxy>();

            if (serviceProxy == null)
            {
                serviceProxy = new NodeServiceProxy(SPFarm.Local);
                serviceProxy.Update(true);
            }

            // With service added to the farm, install instance.
            foreach (SPServer server in SPFarm.Local.Servers)
            {
                if (server.Role != SPServerRole.Invalid)
                {
                    NodeServiceInstance serviceInstance = new NodeServiceInstance(server, service);
                    serviceInstance.Update(true);
                }
            }
        }
예제 #3
0
        private static void StartServiceInstances()
        {
            // loop through all service instances on the current server and see if the one for
            //      this service app is running/not
            foreach (SPServiceInstance serviceInstance in SPServer.Local.ServiceInstances)
            {
                NodeServiceInstance nodeServiceInstance = serviceInstance as NodeServiceInstance;

                // if this one isn't running, start it up
                if ((nodeServiceInstance != null) && (nodeServiceInstance.Status != SPObjectStatus.Online))
                {
                    nodeServiceInstance.Status = SPObjectStatus.Online;
                }
            }
        }