예제 #1
0
        private void CreateServiceApplicationProxy(OceanikServiceApplication serviceApp)
        {
            // get reference to the installed service proxy
            OceanikServiceProxy serviceProxy = SPFarm.Local.ServiceProxies.GetValue <OceanikServiceProxy>();

            // create service app proxy
            OceanikServiceApplicationProxy serviceAppProxy = new OceanikServiceApplicationProxy(
                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);
            }
        }
예제 #2
0
        private void SetupOceanikServiceApp()
        {
            // create a long running op..
            using (var op = new SPLongOperation(this))
            {
                op.Begin();

                try
                {
                    // get reference to the installed service
                    var service = SPFarm.Local.Services.GetValue <OceanikService>();

                    // create the service application
                    OceanikServiceApplication serviceApp = CreateServiceApplication(service);

                    // if the service instance isn't running, start it up
                    StartServiceInstances();

                    // create service app proxy
                    CreateServiceApplicationProxy(serviceApp);
                }
                catch (Exception e)
                {
                    throw new SPException("Error creating Oceanik service application.", e);
                }
            }
        }
예제 #3
0
        private OceanikServiceApplication CreateServiceApplication(OceanikService service)
        {
            // create service app
            OceanikServiceApplication serviceApp = OceanikServiceApplication.Create(
                ServiceAppName.Text,
                service,
                ApplicationPoolSelection.GetOrCreateApplicationPool());

            serviceApp.Update();

            // start it if it isn't already started
            serviceApp.Status = SPObjectStatus.Online;

            // configure service app endpoint
            serviceApp.AddServiceEndpoint(string.Empty, SPIisWebServiceBindingType.Http);
            serviceApp.Update(true);

            // now provision the service app
            serviceApp.Provision();
            return(serviceApp);
        }
예제 #4
0
        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 can hit local server
            SPServer server = SPServer.Local;
            if (server == null)
            {
                ThrowTerminatingError(new InvalidOperationException("SharePoint local server not found."), ErrorCategory.ResourceUnavailable, this);
                SkipProcessCurrentRecord();
            }

            // ensure can hit service application
            var service = farm.Services.GetValue <OceanikService>();
            if (service == null)
            {
                ThrowTerminatingError(new InvalidOperationException("Wingtip Calc Service not found (likely not installed)."), ErrorCategory.ResourceUnavailable, this);
                SkipProcessCurrentRecord();
            }

            // ensure can hit app pool
            SPIisWebServiceApplicationPool appPool = this.ApplicationPool.Read();
            if (appPool == null)
            {
                ThrowTerminatingError(new InvalidOperationException("Application pool not found."), ErrorCategory.ResourceUnavailable, this);
                SkipProcessCurrentRecord();
            }
            #endregion

            // verify a service app doesn't already exist
            var existingServiceApp = service.Applications.GetValue <OceanikServiceApplication>();
            if (existingServiceApp != null)
            {
                WriteError(new InvalidOperationException("Wingtip Calc Service Application already exists."),
                           ErrorCategory.ResourceExists,
                           existingServiceApp);
                SkipProcessCurrentRecord();
            }

            // create & provision the service app
            if (ShouldProcess(this.Name))
            {
                OceanikServiceApplication serviceApp = OceanikServiceApplication.Create(
                    this.Name,
                    service,
                    appPool);

                // provision the service app
                serviceApp.Provision();

                // pass service app back to the PowerShell
                WriteObject(serviceApp);
            }
        }