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