public override void FeatureActivated(SPFeatureReceiverProperties properties) { // install the service var service = SPFarm.Local.Services.GetValue <OceanikService>(); if (service == null) { service = new OceanikService(SPFarm.Local); service.Update(); } // install the service proxy var serviceProxy = SPFarm.Local.ServiceProxies.GetValue <OceanikServiceProxy>(); if (serviceProxy == null) { serviceProxy = new OceanikServiceProxy(SPFarm.Local); serviceProxy.Update(true); } // with service added to the farm, install instance var serviceInstance = new OceanikServiceInstance(SPServer.Local, service); serviceInstance.Update(true); }
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) { OceanikServiceInstance calcServiceInstance = serviceInstance as OceanikServiceInstance; // if this one isn't running, start it up if ((calcServiceInstance != null) && (calcServiceInstance.Status != SPObjectStatus.Online)) { calcServiceInstance.Status = SPObjectStatus.Online; } } }