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

            // create service app proxy
            NodeServiceApplicationProxy serviceAppProxy = new NodeServiceApplicationProxy(
                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
        /// <summary>
        /// Creates the service application.
        /// </summary>
        private void CreateApplication()
        {
            using (SPLongOperation operation = new SPLongOperation(this))
            {
                operation.LeadingHTML  = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "CreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString();
                operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "CreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString();
                operation.Begin();

                try
                {
                    ClubCloudService      service      = ClubCloudService.GetOrCreateService();
                    ClubCloudServiceProxy serviceProxy = ClubCloudServiceProxy.GetOrCreateServiceProxy();

                    // Create the application pool
                    IisWebServiceApplicationPoolSection applicationPoolSectionCasted = this.applicationPoolSection as IisWebServiceApplicationPoolSection;
                    SPIisWebServiceApplicationPool      applicationPool = applicationPoolSectionCasted.GetOrCreateApplicationPool();

                    // Create the service application
                    ClubCloudServiceApplication application = new ClubCloudServiceApplication(
                        this.textBoxServiceName.Text.Trim(),
                        service,
                        applicationPool);
                    application.Update();
                    application.Provision();

                    // Create the service application proxy
                    ClubCloudServiceApplicationProxy proxy = new ClubCloudServiceApplicationProxy(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ServiceApplicationProxyNameTemplate", CultureInfo.CurrentCulture).ToString(),
                            this.textBoxServiceName.Text.Trim()),
                        serviceProxy,
                        application.Uri);
                    proxy.Update();
                    proxy.Provision();

                    if (this.checkBoxIncludeInDefaultProxy.Checked)
                    {
                        SPServiceApplicationProxyGroup group = SPServiceApplicationProxyGroup.Default;
                        group.Add(proxy);
                        group.Update();
                    }

                    operation.EndScript("window.frameElement.commitPopup();");
                }
                catch (Exception ex)
                {
                    SPUtility.TransferToErrorPage(ex.ToString());
                }
            }
        }
예제 #3
0
        public static void SetDefaultServiceApplicationProxy(ParagoServiceApplicationProxy serviceApplicationProxy)
        {
            if (serviceApplicationProxy != null)
            {
                SPServiceApplicationProxyGroup proxyGroup = SPServiceApplicationProxyGroup.Default;

                if (proxyGroup != null)
                {
                    // Remove all existing service application proxies available
                    foreach (ParagoServiceApplicationProxy proxy in proxyGroup.DefaultProxies.OfType <ParagoServiceApplicationProxy>().ToList())
                    {
                        proxyGroup.Remove(proxy.Id);
                    }

                    proxyGroup.Add(serviceApplicationProxy);
                    proxyGroup.Update(true);
                }
            }
        }
예제 #4
0
        protected override void InternalProcessRecord()
        {
            // 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
            NodeServiceProxy serviceProxy = farm.ServiceProxies.GetValue <NodeServiceProxy>();

            if (serviceProxy == null)
            {
                ThrowTerminatingError(new InvalidOperationException("Glyma Node Service Proxy not found (likely not installed)."), ErrorCategory.NotInstalled, this);
                SkipProcessCurrentRecord();
            }

            // ensure can hit service application
            NodeServiceApplicationProxy existingServiceAppProxy = serviceProxy.ApplicationProxies.GetValue <NodeServiceApplicationProxy>();

            if (existingServiceAppProxy != null)
            {
                ThrowTerminatingError(new InvalidOperationException("Glyma Node Service Application Proxy already exists."), ErrorCategory.ResourceExists, this);
                SkipProcessCurrentRecord();
            }

            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))
            {
                NodeServiceApplicationProxy serviceAppProxy = new NodeServiceApplicationProxy(
                    this.Name,
                    serviceProxy,
                    serviceApplicationAddress);

                // provision the service app proxy
                serviceAppProxy.Provision();

                // add the service app proxy to the default service application proxy group
                SPServiceApplicationProxyGroup defaultGroup = SPServiceApplicationProxyGroup.Default;
                defaultGroup.Add(serviceAppProxy);
                defaultGroup.Update(true);

                // pass service app proxy back to the PowerShell
                WriteObject(serviceAppProxy);
            }
        }
        /// <summary>
        /// This method gets invoked when the command is called
        /// </summary>
        protected override void InternalProcessRecord()
        {
            Uri applicationUri = null;
            SPServiceApplication        resolvedApplication = null;
            ClubCloudServiceApplication castedApplication   = null;

            if (this.ServiceApplication == null && string.IsNullOrEmpty(this.Uri))
            {
                this.ThrowTerminatingError(new InvalidOperationException("No service application or Uri was provided."), ErrorCategory.InvalidOperation, this);
            }

            if (this.ServiceApplication != null)
            {
                resolvedApplication = this.ServiceApplication.Read();

                if (resolvedApplication == null)
                {
                    this.ThrowTerminatingError(new InvalidOperationException("Service application not found."), ErrorCategory.InvalidOperation, this);
                }

                castedApplication = resolvedApplication as ClubCloudServiceApplication;

                if (castedApplication == null)
                {
                    this.ThrowTerminatingError(new InvalidOperationException("Service application was not of the correct type."), ErrorCategory.InvalidOperation, this);
                }

                applicationUri = castedApplication.Uri;

                if (string.IsNullOrEmpty(this.Name))
                {
                    this.Name = castedApplication.Name + " Proxy";
                }
            }
            else
            {
                applicationUri = new Uri(this.Uri);
            }

            if (this.ShouldProcess(this.Name))
            {
                // Ensure the service exists
                ClubCloudService.GetOrCreateService();

                // Ensure the proxy exists
                ClubCloudServiceProxy serviceProxy = ClubCloudServiceProxy.GetOrCreateServiceProxy();

                // Create the service application proxy
                ClubCloudServiceApplicationProxy proxy = new ClubCloudServiceApplicationProxy(this.Name, serviceProxy, applicationUri);
                proxy.Update();
                proxy.Provision();

                if (this.DefaultProxyGroup.ToBool())
                {
                    SPServiceApplicationProxyGroup group = SPServiceApplicationProxyGroup.Default;
                    group.Add(proxy);
                    group.Update();
                }

                this.WriteObject(proxy);
            }
        }