public SPServiceApplicationProxy CreateProxy(string name, SPServiceApplication serviceApplication, SPServiceProvisioningContext provisioningContext) { #region validation if (serviceApplication.GetType() != typeof(CalcServiceApplication)) { throw new NotSupportedException(); } if (serviceApplication == null) { throw new ArgumentNullException("serviceApplication"); } #endregion // verify the service proxy exists CalcServiceProxy serviceProxy = (CalcServiceProxy)this.Farm.GetObject(name, this.Farm.Id, typeof(CalcServiceProxy)); if (serviceProxy == null) { throw new InvalidOperationException("CalcServiceProxy does not exist in the farm."); } // if the app proxy doesn't exist, create it CalcServiceApplicationProxy applicationProxy = serviceProxy.ApplicationProxies.GetValue <CalcServiceApplicationProxy>(name); if (applicationProxy == null) { Uri serviceAppAddress = ((CalcServiceApplication)serviceApplication).Uri; applicationProxy = new CalcServiceApplicationProxy(name, serviceProxy, serviceAppAddress); } return(applicationProxy); }
private void CreateServiceApplicationProxy(CalcServiceApplication serviceApp) { // get reference to the installed service proxy CalcServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <CalcServiceProxy>(); // create service app proxy CalcServiceApplicationProxy serviceAppProxy = new CalcServiceApplicationProxy( ServiceAppName.Text + " Proxy", serviceProxy, serviceApp.Uri); serviceAppProxy.Update(true); // provision service app proxy serviceAppProxy.Provision(); // start it if it isn't already started if (serviceAppProxy.Status != SPObjectStatus.Online) { serviceAppProxy.Status = SPObjectStatus.Online; } serviceAppProxy.Update(true); // add the proxy to the default group if selected if (DefaultServiceApp.Checked) { SPServiceApplicationProxyGroup defaultGroup = SPServiceApplicationProxyGroup.Default; defaultGroup.Add(serviceAppProxy); defaultGroup.Update(true); } }
protected override void InternalProcessRecord() { #region validation stuff // ensure can hit farm SPFarm farm = SPFarm.Local; if (farm == null) { ThrowTerminatingError(new InvalidOperationException("SharePoint farm not found."), ErrorCategory.ResourceUnavailable, this); SkipProcessCurrentRecord(); } // ensure proxy installed CalcServiceProxy serviceProxy = farm.ServiceProxies.GetValue <CalcServiceProxy>(); if (serviceProxy == null) { ThrowTerminatingError(new InvalidOperationException("Wingtip Calc Service Proxy not found (likely not installed)."), ErrorCategory.NotInstalled, this); SkipProcessCurrentRecord(); } // ensure can hit service application CalcServiceApplicationProxy existingServiceAppProxy = serviceProxy.ApplicationProxies.GetValue <CalcServiceApplicationProxy>(); if (existingServiceAppProxy != null) { ThrowTerminatingError(new InvalidOperationException("Wingtip Calc Service Application Proxy already exists."), ErrorCategory.ResourceExists, this); SkipProcessCurrentRecord(); } #endregion Uri serviceApplicationAddress = null; if (ParameterSetName == "Uri") { serviceApplicationAddress = _uri; } else if (ParameterSetName == "ServiceApplication") { // make sure can get a refernce to service app SPServiceApplication serviceApp = ServiceApplication.Read(); if (serviceApp == null) { WriteError(new InvalidOperationException("Service application not found."), ErrorCategory.ResourceExists, serviceApp); SkipProcessCurrentRecord(); } // make sure can connect to service app ISharedServiceApplication sharedServiceApp = serviceApp as ISharedServiceApplication; if (sharedServiceApp == null) { WriteError(new InvalidOperationException("Service application not found."), ErrorCategory.ResourceExists, serviceApp); SkipProcessCurrentRecord(); } serviceApplicationAddress = sharedServiceApp.Uri; } else { ThrowTerminatingError(new InvalidOperationException("Invalid parameter set."), ErrorCategory.InvalidArgument, this); } // create the service app proxy if ((serviceApplicationAddress != null) && ShouldProcess(this.Name)) { CalcServiceApplicationProxy serviceAppProxy = new CalcServiceApplicationProxy( this.Name, serviceProxy, serviceApplicationAddress); // provision the service app proxy serviceAppProxy.Provision(); // pass service app proxy back to the PowerShell WriteObject(serviceAppProxy); } }
public CalcServiceApplicationProxy(string name, CalcServiceProxy proxy, Uri serviceAddress) : base(name, proxy, serviceAddress) { // create instance of a new load balancer _loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceAddress); }